Commands are sorted by their random UUID, which makes them hard to find when several commands are defined. Attached patch sorts them by name. Reproducible: Always
Created attachment 101241 [details] sort commands by name patch
I think they are shown in the order you define them in the desktop (which shouldn't be based on the uuid). If we want to sort them, shouldn't we be sorting them on the desktop side so the ordering is the same on both sides?
They are not. key{name,command} entries are stored/transmitted in an JSON object, which is unordered by definition [1]. The ordering by key probably is an implementation detail of the used JSON library. I.e. restoring commands from JSON orders them by key. Same ordering on both sides seems like a good idea. This would also allow for custom ordering (without having to resort to some common prefix). A protocol change would be required however. I see two approaches: * Add a sortIndex field and sort on both sides. {key:{name,command,idx},...} * Send by Array. [{key,name,command},...] I prefer the second, since this is how you express ordered data in JSON and I expect it to lead to a simpler implementation. What is your opinion? [1] json.org
Changing the protocol should be done in a backwards compatible way, and I don't think the benefit is worth the hassle. Let's use this patch for now, so at least we have the commands sorted on the side you use them. If you send new patches, it would be good if you use http://reviewboard.kde.org instead, as it's easier to discuss code changes there :) PS: I'll try to spell your name correctly this time!
Git commit 5320c3c226b7d09c4f7cd043508364e053f0b899 by Albert Vaca, on behalf of Thomas Posch. Committed on 29/09/2016 at 10:57. Pushed by albertvaka into branch '1.x'. Make commands sorted by name A +40 -0 src/org/kde/kdeconnect/Plugins/RunCommandPlugin/CommandEntry.java M +17 -11 src/org/kde/kdeconnect/Plugins/RunCommandPlugin/RunCommandActivity.java M +2 -2 src/org/kde/kdeconnect/UserInterface/List/EntryItem.java http://commits.kde.org/kdeconnect-android/5320c3c226b7d09c4f7cd043508364e053f0b899
Another (easier) solution that wouldn't require changing the protocol would be to display them also in alphabetical order in the desktop plugin settings. This would work regardless of how they are stored and sent internally.
Git commit 91cf466ee2f04daad20ab4f4a474a92fdb0b1e38 by Albert Vaca, on behalf of Thomas Posch. Committed on 30/09/2016 at 10:56. Pushed by albertvaka into branch '1.x'. Sort commands by name, as we do on Android REVIEW: 129076 M +3 -0 plugins/runcommand/runcommand_config.cpp http://commits.kde.org/kdeconnect-kde/91cf466ee2f04daad20ab4f4a474a92fdb0b1e38