it’s so confusing that the order changes when adding IDENTICAL strings to BOTH filenames. Is this really how it’s supposed to be?
What you expecting called natural sorting. Mac employed natural sorting back in 90s. What you get is legitimate Alphabetical sorting which used by Linux and Windows. Natural sorting parses tokens in the string and compares them. Alphabetical sorting compares two strings by comparing individual characters at same index (position). Alphabetical sorting is quite common as it simpler to implement (or rather harder to screw up) and yields predictable results
One of many libraries for Python which implements natural sorting https://github.com/SethMMorton/natsort
I believe it’s correct. If you sort say “A”, “AA”, “AAA” then you get
- A
- AA
- AAA
Because the first character is compared, which are all the same, then the second. The first one has no second character, so it comes first. The second has no third character, so it comes before the third item.
In your scenario, you have:
- 5
- 5.5
The first characters are the same, so it looks at the second character. Item 1 has no second character so it comes first.
Scenario 2:
- 5.5 A
- 5 A
The first character is the same, so it looks at the second character. The second characters are “.” and " ". The “.” comes first in the character ranking so is shown first.
yes yes I get what you’re saying but it’s still odd. Didn’t humans do this differently in the old analog days? I’m sure any human when working with a real paper archive in front of him, order 5 A before 5.5 A. Perhaps it has something to do with viewing 5 as 5.0 and 5.00, since they are mathematically equivalent, and come before 5.5. Although humans would also be inconsistent because they would order 5.9 before 5.11 if the context were to be chapters going from 5.9 -> 5.10 -> 5.11. But if these papers were to represent values, humans would order 5.9 AFTER 5.11. And computers obviously don’t make exceptions based on context like humans do.
edit: if I understand correctly, I’d be cleaner if spaces come first in character ranking of ANY character. Perhaps that’d make it more human readable.
If a person was ordering them, they would do it in numerical order. Despite these being numbers, the computer is still ordering in alphabetical order.
Doing it the way a person would requires the file manager to understand context, which requires a lot more logic for arguably little benefit.
I note that your season and episode start with 0 as well (S01E05), in order to ensure the alphabetical ordering works. Perhaps you should use 5.0 to solve this in the same way.
that all makes sense to me. how would you want it to work?
deleted by creator
I’ve always felt like numbers should be ordered after letters. A-Z then 0-9.
i’m not quite sure whether i understood your question but this seems to be right. the
5fromS01E05.*5*.mkvis higher in the alphabet thenmfromS01E05.*m*kvso it belongs above that entry.Always been weird, this is why for instance my ll alias is:
alias ll='LC_COLLATE=C ls -alFh' alias ls='ls --color=auto'The correct solution is to make sure all files to be sorted have equivalent numerical structure, like 5.0 and 5.5
Same with eg. 05 and 10



