4 ms·
I thought this was pretty well known. E.g. the macOS Foundation library even exposes NSString.localizedStandardCompare() [1] which implements the sorting algori
by meindnoch 1y ago
I thought this was pretty well known. E.g. the macOS Foundation library even exposes NSString.localizedStandardCompare() [1] which implements the sorting algorithm used by Finder, and should be used by any well-behaved macOS application. Windows uses StrCompareLogical [2].
[1] https://developer.apple.com/documentation/foundation/nsstring/localizedstandardcompare(_ https://developer.apple.com/documentation/foundation/nsstrin...:)
[2] https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-strcmplogicalw https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/...
- nielsbot 1y agoI tried it just for kicks. The Finder sorts these as: IMG_20250820_095716_607.jpg IMG_20250820_103857_991.jpg IMG_20250820_103903_811.jpg IMG_20250820_055436307.jpg IMG_20250820_092016029_HDR.jpg IMG_20250820_092440966_HDR.jpg IMG_20250820_092832138_HDR.jpg Whereas `ls -l` gives me IMG_20250820_055436307.jpg IMG_20250820_092016029_HDR.jpg IMG_20250820_092440966_HDR.jpg IMG_20250820_092832138_HDR.jpg IMG_20250820_095716_607.jpg IMG_20250820_103857_991.jpg IMG_20250820_103903_811.jpg
- freetime2 1y agoI would have assumed it worked the same as ls, so I found the article interesting. But now that I know, I think this way is better. I can’t think of any case where I would need purely alphabetical sort. In most photo browsing apps, photos will be sorted by timestamp rather than filename. If I really needed it to sort properly in file explorer, I would try sorting on created date. And failing that I would probably just normalize the file names.