How to sort a list by first non-modifier character?

OK -- here's a complete version, based on what I understand @August's needs to be (from here).

It grabs the list of triggers from a macro selected in the KM Editor and sorts them into the following order:

  1. Hot key Fn triggers sorted by number (so F9 is before F10) and sub-sorted by modifiers
  2. All other hot key triggers, ASCII-sorted by key, sub-sorted by modifiers
  3. All other triggers, in ASCII sort order of the triggers' descriptions -- this is not the same as you see in the GUI! For example, the This application: Finder: Activates is described as "Application 'Finder' activates", so sorts before "At system sleep".

It then rearranges (actually, adds copies of the triggers in order, then deletes the originals from the "front" of the trigger list) the triggers of the selected macro, leaving a (hopefully!) tidier list...

Please try this on copies of macros first -- for your own peace of mind, if nothing else. It's been extensively tested, but there's no way I could try it on every possible trigger combo...

Replace Triggers with Sorted Ones.kmmacros (12.3 KB)

Image

I know there are improvements to be made -- for example, I've left in the repeat loop to delete "old" triggers one-by-one so you can see what's happening, but it would be better to

delete triggers 1 thru (count of triggerList) of the selectedMacro

...and nuke them in one operation. I look forward to seeing what other changes you all make!

1 Like