Match Finder (and KM) sort order?

I have a list of macros in a variable that matches my list of macros in KM. The order they display in KM matches the order they display in Finder…but that doesn't match what happens with KM's "Sort" filter, nor with the unix sort command with any of its various sorting options.

A brief example; here's part of my list in Finder/KM:

__ AppWatchAdd 1.2
__ AppWatchDel 1.2
__ AppWatchLauncher 1.2
__ Browse KM Wiki topics
__ Demo- Updater for macros 1.3
__ Macro Usage Counter 2.4
...
app-Terminal
app-Zork
Conversions
Global Macro Group
Help Files Only
Mouse Free Zone

There are any number of ways to sort in KM, but none look anything like that. Here's the built-in sort filter, for example, from the top of its order:

Conversions
Global Macro Group
Help Files Only
Mouse Free Zone
Open From Folder
Open From Folder SLOW ORIGINAL
VPN Connection [Posted]
__ AppWatchAdd 1.2
__ AppWatchDel 1.2
__ AppWatchLauncher 1.2
...

Basically, in Finder and KM, the special characters all come first, then alpha order. The Sort filter in KM uses the same algorithm as the sort Terminal command (I would guess that's what it uses?). Trying all the options in Terminal with sort, none of them get close to the above.

Is there any way to sort the list in the same order for both KM/Finder and my variable, short of writing my own sorting macro?

-rob.

Which built in sort filter are you talking about?

The Filter action?

Both sorting macros and the Filter Sort use localizedStandardCompare, which will sort based on the locale, which may vary from place to place.

But they should give the same results.

In my testing, with my locale, both Filter Sort and macros sort “_” to the front.

Argh, my apologies. This is what I get for working too late into the evening: I was sorting the wrong variable but displaying the one I wanted to sort (which was, of course, sorted wrong). Please delete this topic.

-rob.

1 Like

Topics should almost never be deleted - there is always something folks can learn.

"Don't write code after bedtime, kids!"

:slight_smile:

-rob.

1 Like