macOS Catalina - how to set up Finder to use file sorting logic same as ls command (alphabetical order, not “natural”)? [duplicate]

apple.stackexchange https://apple.stackexchange.com/questions/375086

Question

I noticed today that Finder has some strange logic of sorting files by name and I cannot figure out why is that.

Screenshot 1 - folder in "column" view with folder's options opened: enter image description here

Screenshot 2 - same folder in "list" view, sorted by "Name" column: enter image description here

Screenshot 3 - output of ls -al command in terminal, correct and expected file sorting: enter image description here

EDIT: I created a testing folder with integer file names only and the behaviour is the same.

Finder:
enter image description here

Terminal:
enter image description here

How can I change Finder to use the same logic like ls command?

Unfortunately, linked duplicate question doesn't answer my question above, only explains Finder's logic and behaviour in sorting files. What I would like to achieve, as stated in title and the question above, is to force Finder to sort files in alphabetical, not "natural" order.

Was it helpful?

Solution

Apple's Finder has been using "natural" sort order (where strings of digits are ordered as single characters) for file names for nearly 20 years, since OS X 10.0 There's no way to change it as far as I know. If you want the other kind of sort order, you have to use Terminal or a 3rd party app.

OTHER TIPS

Essentially, Finder is treating the numbers up to the first letter as its sort criterion.

So, as far as Finder is concerned, the order is 'correct' for

  • 0
  • 2
  • 6
  • 298
  • 2655522

It is not considering the entirety of the name as a hexadecimal figure.

Based on your edit - terminal is 'wrong' - 6 is smaller than 2655522

It's still down to "if you want a computer to sort 'properly' give it leading zeroes".

I also made a test folder - the logic is perhaps awkward, but it is actually logical, for a given definition.

enter image description here

I think what Terminal is doing is sorting numbers like they were letters, so like e would sort after aabbaccd so 6 sorts after 2655522

Maybe you might not know this but there is another button in your toolbar that also sorts your files and sometimes overrides or conflicts with the "Finder" preference setting you have. Check it out and make sure it's set to "none"

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top