How does finder sort folders when they contain digits and characters?
I can't figure it out how to sort folders by name in Finder.
My expected results should look like this:
0629e7bc-8110-4db9-aaa9-b67b0b73743d
06a409e1-98c6-4bf4-afa4-c814f7899d82
0a3a5c12-e459-4aa0-b9cb-30b544013215
0c14581f-31d8-4961-a14f-11afc40e47f9
0fe8970c-6338-46ca-bc16-f7867b271480
129855c4-7dbe-4a9f-a100-28b1d3d02340
1522e288-8a81-4298-aefc-f334cb088a53
180d430b-76f9-401f-845a-cb395bc1eba0
1a01a936-bedf-4758-971a-d4886ee8d281
....
But instead it looks like this:
Here are my settings:
Grouping is turned off.
I think this is a bug. Grouping is turned off everywhere (grouping doesn't change anything here). I've deleted .DS_Store
files.
I am running macOS Mojave 10.14.5 (18F132)
Even if I switch to another view, it does not work.
What else could I try to fix this?
Solution 1:
I think this is alphabetical vs natural search order being used in Terminal(or wherever the code block comes from) and Finder respectively.
Why is a folder which starts with a 2 on the bottom?
Because it is 27 which is treated as a block while sorting and is greater than other single numbers which are also being treated as blocks. Another example is in the longer screenshot. 5f
comes before 06a
as 5 is smaller than 06.
Numbers are smaller than alphabets in both cases.
In the code block, we have character-wise sorting where single digits are being compared. So a larger number like 062
sometimes comes before 06a
as 2 is smaller than a.
For example, in alphabetical sorting "z11" would be sorted before "z2" because "1" is sorted as smaller than "2", while in natural sorting "z2" is sorted before "z11" because "2" is sorted as smaller than "11".
Alphabetical sorting:
z11
z2
Natural sorting:
z2
z11
Functionality to sort by natural sort order is built into many programming languages and libraries
https://en.wikipedia.org/wiki/Natural_sort_order
Mac OS X sorting is based on the Unicode Collation Algorithm (Technical Standard UTS #10) defined by the Unicode Consortium. This standard provides a complete and unambiguous sort ordering for all Unicode characters and is available on the Unicode Consortium website (http://www.unicode.org).
There are no hints that this behaviour can be changed in Finder. It was observed in 2002-03:
http://hints.macworld.com/article.php?story=20021002061850171
https://apple.stackexchange.com/a/375244/313842 Comments under here suggest using apps like Pathfinder.
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFileSystem/Articles/SortingRules.html#//apple_ref/doc/uid/20002377-BCIJIGDE
- https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemDetails/FileSystemDetails.html