FINDER - macOS - sort by Name

Has anyone else noticed when you tell Finder to “sort by name” its strange?
I have 255 files named “file$XX.dat” where XX is 00 to FF
now I don’t expect them to be sorted in NUMERIC order…

but I don’t expect THIS order

$5E $5F $06 $6A $6B $07 $08 $09 $10 ..... $19 $21 ...$33 $40

I would expect them to be sort by the alphanumeric name

$00 ... $0F
$10....$1F
etc.

how truly curious

yes, yes it is…

not only that but the Xcode Asset Catalog, sorts them the same strange way

as does this method I wrote about “Sorting like finder” way back

Its really curious since its not considering the $XX part as numeric OR lexical
Very odd

but in any comparison method… ."$06" is LESS than “$5E” … :frowning:

It makes it really hard to find a file (via EyeBall Reader 1.0) when they are not in the order expected.

Unless it ignores the $ and the leading zero.

true… but its still “wrong”

1 Like

I have found articles that discuss this (or something similar) and eludes to a difference between “sort by” and “arrange by”… but none of the “solutions” seem to be able to be applied in Catalina

1 Like

If that is the case, someone (probably an intern or someone with reduced experience) thinks that it is right <shakesHead/>

I also have NSStringArraySortMBS in the plugin, which sorts a Xojo array using NSStringCompareMBS, which also uses Apple’s sorting including the sort by number option.

Seems like it doesn’t work for hex numbers, but it works fine for numbers.

Yeah I cant figure what they are doing that things come out the ay they are
Its not obvious

Christian… its not a “hex” number it is two alphanumeric characters. Finder should not be attempting to derive a “context” from a file name

Looks to me like:

  1. Strip the non-numeric part of the string
  2. Take a Val() of the remaining number and order it by that.

This is not sorting filenames using Xojo… it is sorting them in Finder… so no manipulation of the filename is possible

I get that. Just my take on what MacOS is doing “under the hood”. No idea why…
Are you seeing the same thing if the files don’t have the “$” prefix?

I created another set of files that used $xxx where xxx was completely numeric, and those sorted correctly

You know what it looks like to me?

It looks like handling designed to accommodate designers, these weird people who don’t source control their work, who might name a document:

Doc-a
Doc-a1
Doc-a1-good
Doc-a1-new-good

and so on…

1 Like

That doesn’t explain seeing this order…

thats about what I thought it might be doing but that would give something different than

$5E $5F $06 $6A $6B $07 $08 $09 $10 … $19 $21 …$33 $40

as the $06 $07 $08 $09 would be closer to the beginning of the list

Its really a weird organization

Did you guys not see my earlier reply? :sunglasses:

MacOS treats numbers as a single character for sorting.

The list is sorted exactly the way MacOS was designed to. Stupidly. But that’s the way it’s done it for like 20 years.