Based on this description, I have no idea how the following would be sorted:
• photo.jpg
• photo1.jpg
• photo01.jpg
• photos.jpg
Based on this description, I have no idea how the following would be sorted:
• photo.jpg
• photo1.jpg
• photo01.jpg
• photos.jpg
There's a user expectation that photo20.jpg comes after photo3.jpg.
There's no user expectation around whether photo1.jpg or photo01.jpg comes first. Just like there's no user expectation around whether photo1.jpg or Photo1.jpg comes first. Users also don't have the slightest idea about what order punctuation gets sorted in.
Just sort the things that matter in the way users expect (natural sort order) and come up with something reasonably consistent for the rest.
my user expectation is the opposite
i get what you're saying but it's not achievable in practice, at least not consistently
I expect photo20.jpg to come first.
> There's no user expectation around whether photo1.jpg or photo01.jpg comes first.
Clearly photo01.jpg comes first.
> Just like there's no user expectation around whether photo1.jpg or Photo1.jpg comes first.
Of course Photo1.jpg comes first because uppercase comes before lowercase.
It really sounds like you're using the word "user" to mean "dumb" and I wonder, what got you to the point that you started considering yourself an expert on "dumb" and feeling the need to defend "dumb" ?
I'm sorry but it all comes off so condescending, like "users" are a different+lower species or something.
Yes. An algorithm must be unambiguosly specified for all possible inputs.
And it is. It's just that some outputs may not match what the user expects. TFA's preferred algorithm (simple lexicographic sorting) matches user expectations 90% of the time. The algorithm actually in use on most OSs (simple lexicographic sorting + treat consecutive digits as combined numbers) matches expectations 99% of the time. An algorithm that matches expectations 100% of the time doesn't exist. Shouldn't we pick the 99% algorithm?
(I am admittedly making up the actual percentages, but you get the point.)
Well-designed machines quite _often_ operate against "user" expectations when those expectations are wrong.
For instance say if I charge my phone for an hour, it'll last for a day. How long will it last when I charge it for two hours? Because in practice the answer is either "also a day" or it is "the battery catches on fire", this machine acts _against_ user expectations and stops charging the phone after an hour.
Maybe an even better example: coins! I dunno about coins in the US but but get this: the 5 eurocent coin is _bigger_ than the 10 eurocent coin! I dunno why, or if there even is a good reason for that, but it doesn't seem to bother "users" of money (e.g. everybody) when they have to sort out cash.
Anyway my point is that even if _some_ (but definitely not all!) people may expect numerical sorting, doesn't mean that they're right ... and it's not like lexicographic sorting is rocket science and zero padding .. well I think you said you don't like the way it looks, but I actually think it looks very neat because things line up and it's actually easier to read for me, as well :)
It's dumbing things down, in a bad way. It's like hiding the inner workings of stuff, and it's a mistake to think that even if somebody is not familiar with computers that they are _stupid_. People might even get curious and figure out that numbers come before uppercase and those come before lowercase. And maybe one day someone comes along and says "you know that's because of ASCII?" and they learn a thing! Which is cool.
Instead it's like you're painting people scratching their heads wondering "why number not go up?"
photo1 photo01 photo001 photo0001 photo2
So the shorter representation of the same number comes first. It does make intuitive sense to me.
> photo1 photo01 photo001 photo0001 photo2
What you enumerated is known as "ascending lexicographical ordering" and has nothing to do with "the shorter representation of the same number", but instead the ASCII[0] character values in each file name.
0 - https://man.freebsd.org/cgi/man.cgi?query=ascii&apropos=0&se...
Good catch. I did not closely inspect the ordering initially presented, which was:
photo1 photo01 photo001 photo0001 photo2
This does not represent a valid sort order based solely on file names produced by `ls`, which would be: photo0001 photo001 photo01 photo1 photo2I guess?
photo.jpg
photo[nine].jpg
photos.jpg
photos[zero][one].jpg