1

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.

0

3 Answers 3

4

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.

3
  • 20 years?! Wow! I'm extremely ashamed to admit that this is the first time in my life I've noticed this behaviour, possibly because I usually use Terminal more than Finder. I will mark this as accepted because it has concrete answer. Thank you for the effort of finding that link too! :)
    – errata
    Commented Nov 15, 2019 at 16:09
  • @errata sorry I could not name an app which I am certain can do it. Maybe Pathfinder. Commented Nov 15, 2019 at 17:12
  • No problem, I am aware of Pathfinder, but I’d rather not install Finder replacement, I’ll just live with it as I did up until now :)
    – errata
    Commented Nov 15, 2019 at 17:16
3

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

4
  • Thanks for explaining! In my every day's work, Finder's logic is just confusing and not helpful at all, so I'd like to instruct Finder not to sort them that way. I hope that's possible somehow. Unfortunately, prepending zeros is not an option at this point.
    – errata
    Commented Nov 13, 2019 at 18:20
  • 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
    – Tetsujin
    Commented Nov 13, 2019 at 18:23
  • @errata See natural sort on wikipedia
    – anki
    Commented Nov 13, 2019 at 21:11
  • Thank you for all explanations, but none of them actually answers the question - how to make Finder sort alphabetically instead of using "natural" sort order?
    – errata
    Commented Nov 15, 2019 at 13:16
1

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

1
  • I checked that setting too and it is set to "None", but behaviour is still the same.
    – errata
    Commented Nov 13, 2019 at 18:11

Not the answer you're looking for? Browse other questions tagged .