Earlier quoted context omitted.
Ah yes sorry, 1.10 comes after 1.2 because 10 is bigger than 2 (so in fact different from your example). But assuming your original list is a list of versions (which seems reasonable given the presence of multiple decimal points for some cases), then that’s the order you’d want. If you have non-integer numbers in your filenames then it won’t give the order you want, but there isn’t going to be a rule that works for a…
> But assuming your original list is a list of versions (which seems reasonable given the presence of multiple decimal points for some cases), then that’s the order you’d want. What level of assumption is here expected from the sorting-system, would it have to process ALL entries of the list to find multiple decimal-points and then assume that they are ALL versions and not numbers? How to treat this on different loca…
When I say “alphabetical order”, I mean “alphabetical order”
331–340 of 385 posts
Re: When I say “alphabetical order”, I mean “alphabetical order”
#332Earlier quoted context omitted.
Ah yes sorry, 1.10 comes after 1.2 because 10 is bigger than 2 (so in fact different from your example). But assuming your original list is a list of versions (which seems reasonable given the presence of multiple decimal points for some cases), then that’s the order you’d want. If you have non-integer numbers in your filenames then it won’t give the order you want, but there isn’t going to be a rule that works for a…
I was with you until this point, but 1.2 is bigger than 1.10, because 1.2 is a shortened version of writing 1.20 _unless_ you explicitely want these to be version numbers or something like that. The normal expectation would be to treat numbers as, well, mathematical numbers, and not SemVer, especially if we only have one decimal point, don't you think?
Re: When I say “alphabetical order”, I mean “alphabetical order”
#333Earlier quoted context omitted.
It feels like this algorithm could be improved though. If a number has leading zeros you probably don't want to sort it numerically. That said the author's situation where it's numerical and different lengths seems likely rare enough that it probably isn't worth complicating things.
The leading zero isn't an issue because it will sort correctly under both systems. The issue OP is having is that he's adding random numbers after the hhmmss section. If instead he added a delimiter before the random number the files would sort correctly under both systems as well, e.g. hhmmss_num.
> where it's numerical and different lengths
Re: When I say “alphabetical order”, I mean “alphabetical order”
#334Numbers aren't in the alphabet. So no, you don't mean alphabetical order.
Re: When I say “alphabetical order”, I mean “alphabetical order”
#335it is neither basic nor simple. Have you ever heard of UTF-8 and locales?
Here is an exercise for the curious reader: Pick any UTF-8 string "a", and another one "b", so that in increasing lexicographical order "a" sorts after "a+b" ("a" concatenated by "b"). ("a" > "a+b")
Re: When I say “alphabetical order”, I mean “alphabetical order”
#336Earlier quoted context omitted.
> But assuming your original list is a list of versions (which seems reasonable given the presence of multiple decimal points for some cases), then that’s the order you’d want. What level of assumption is here expected from the sorting-system, would it have to process ALL entries of the list to find multiple decimal-points and then assume that they are ALL versions and not numbers? How to treat this on different loca…
It has nothing to do with decimal points. It just looks at any contiguous sequence of digits and treats it as a single character for the purposes of sorting. The decimal point could be any other character and the behavior would be the same.
Decimal numbers are treated as strings and will have a completely different order, with digits after the decimal point sorted differently to whole numbers without fractions?
Or you mean every set of continuous digits within the same string are considered as individual whole number?
Depending on the decision, either lists of decimal numbers or lists of version numbers will be sorted wrong.
--> This could be covered by adjusting the logic based on the amount of decimal points.
And the logic complexity keeps increasing, up to an arbitrary point of "no, this will not be considered", resulting in an unpredictable user-experience of sorting...
Re: When I say “alphabetical order”, I mean “alphabetical order”
#337Earlier quoted context omitted.
That's why we have all this LC_* stuff in Linux, which you can configure to your needs: export LC_MEASUREMENT="de_DE" export LC_MONETARY="de_DE" export LC_PAPER="de_DE" export LC_CTYPE=de_DE.UTF-8 export LC_MESSAGES="en_US.UTF-8" export LC_RESPONSE="en_US.UTF-8" export LC_TIME=en_US.UTF-8 Mix in your Swedish or Swaheli, maybe even the Vatican State: e.g. de_DE, sw_TZ, it_VA (not guaranteed ;-).
> export LC_TIME=en_US.UTF-8 Why would you do this to yourself?
Re: When I say “alphabetical order”, I mean “alphabetical order”
#338Earlier quoted context omitted.
To change it per user, set it in the user's hive instead of in the local machine hive (e.g. HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE)
TIL they are called "hives". Windows Registry is an interesting thing. Even casual users have to interactive with it once or twice w/o fully understand it. https://learn.microsoft.com/en-us/windows/win32/sysinfo/regi...
Re: When I say “alphabetical order”, I mean “alphabetical order”
#339Earlier quoted context omitted.
Have you ever copied a file?
Yes, have you never edited the metadata? Also most filesystems these days preserve it when copied, e.g. my camera's EXFAT filesystem on an SD card gets the creation date preserved when I copy it to my PC or NAS, or between NAS & laptop later.
Is your suggestion that people edit the metadata to get the sorting they want? madness...
Re: When I say “alphabetical order”, I mean “alphabetical order”
#340Earlier quoted context omitted.
Yes, have you never edited the metadata? Also most filesystems these days preserve it when copied, e.g. my camera's EXFAT filesystem on an SD card gets the creation date preserved when I copy it to my PC or NAS, or between NAS & laptop later.
> Yes, have you never edited the metadata? I don't even know what that means. And just because some OS's copy the creation date doesn't mean all of them do. Specifically, the most popular desktop OS -- Windows -- doesn't. (And it has nothing to do with your filesystem. It's your OS.)
Obviously something like:
touch -t 202309271530 myfile.txt