# Palette Macro Prefixes and Sort Order?

@peternlewis I tried adding Hex numbers as palette sequence numbers, and KM doesn't sort it the way I thought it would:

Here's how KM sorted them:

``````0A)Item 10
0B)Item 11
0C)Item 12
0D)Item 13
0E)Item 14
0F)Item 15
01)Item 1
1A)Item 26
1B)Item 27
1C)Item 28
1D)Item 29
1E)Item 30
1F)Item 31
02)Item 2
2A)Item 42
2B)Item 43
2C)Item 44
2D)Item 45
2E)Item 46
2F)Item 47
03)Item 3
04)Item 4
05)Item 5
06)Item 6
07)Item 7
08)Item 8
09)Item 9
10)Item 16
11)Item 17
12)Item 18
13)Item 19
14)Item 20
15)Item 21
16)Item 22
17)Item 23
18)Item 24
19)Item 25
20)Item 32
21)Item 33
22)Item 34
23)Item 35
24)Item 36
25)Item 37
26)Item 38
27)Item 39
28)Item 40
29)Item 41
30)Item 48
31)Item 49
32)Item 50
``````

Here's what I would have expected:

``````01)Item 1
02)Item 2
03)Item 3
04)Item 4
05)Item 5
06)Item 6
07)Item 7
08)Item 8
09)Item 9
0A)Item 10
0B)Item 11
0C)Item 12
0D)Item 13
0E)Item 14
0F)Item 15
10)Item 16
11)Item 17
12)Item 18
13)Item 19
14)Item 20
15)Item 21
16)Item 22
17)Item 23
18)Item 24
19)Item 25
1A)Item 26
1B)Item 27
1C)Item 28
1D)Item 29
1E)Item 30
1F)Item 31
20)Item 32
21)Item 33
22)Item 34
23)Item 35
24)Item 36
25)Item 37
26)Item 38
27)Item 39
28)Item 40
29)Item 41
2A)Item 42
2B)Item 43
2C)Item 44
2D)Item 45
2E)Item 46
2F)Item 47
30)Item 48
31)Item 49
32)Item 50
``````

What's going on? Thanks.

Keyboard Maestro uses a number-aware sort.

So, for example the sort order will be:

• 1
• 2
• 3
• 10
• 20
• 30

The number aware is not hex, just decimal numbers.

So 0 comes before 1, and 1 (including 01) comes before 2.

I agree, that is a little odd for this specific case where you could easily consider the two characters as separate characters, but thats not how the sorting characters really work - the sorting characters are really â€śnot displayed charactersâ€ť. The sort still works the same way it always does, using the whole string, and doing number aware, case insensitive sorting.

So for sorting characters either use all numbers, or all letters (of one case), or both separately (ie, 00â€¦99, AAâ€¦ZZ). So a letter followed by a number will always work as expected since it will always be a single digit, so you can include A0â€¦A9,AAâ€¦AZ,B0â€¦B9, â€¦ ,Z0â€¦Z9,ZAâ€¦ZZ.

4 Likes

Thanks for the great explanation. That's one of the things I appreciate about you - your ability to explain things so clearly.

3 Likes