6 ms·
The sort rules are simple (1). Treat any consecutive sequence of digits as a number when sorting. So for example version numbers (which must be massively more c
by Certhas 1y ago
The sort rules are simple (1). Treat any consecutive sequence of digits as a number when sorting. So for example version numbers (which must be massively more common than decimals in filenames) work correctly, and 5.9 is indeed smaller than 5.10 and the latter is not identical to 5.1 .
Given that this idea goes back more than two decades, has been the default behaviour of the most used OSes for many years, with no major outcry, I think empirically we can be fairly certain that it does not routinely lead to a lot of surprises and confusion.
(1) https://en.m.wikipedia.org/wiki/Natural_sort_order https://en.m.wikipedia.org/wiki/Natural_sort_order
- xigoi 1y ago> Treat any consecutive sequence of digits as a number when sorting. Based on this description, I have no idea how the following would be sorted: • photo.jpg • photo1.jpg • photo01.jpg • photos.jpg
- crazygringo 1y agoDoes it matter? 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.
- kiitos 1y ago> There's a user expectation that photo20.jpg comes after photo3.jpg. my user expectation is the opposite i get what you're saying but it's not achievable in practice, at least not consistently
- pixl97 1y agoIt sounds like a problem with too many expectations therefore someone will be disappointed.
- xigoi 1y ago> Does it matter? Yes. An algorithm must be unambiguosly specified for all possible inputs.
- Wowfunhappy 1y ago> 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.)
- tripzilch 1y agoI get your point but I still disagree (also about the percentages btw). Can you also get _my_ 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?"
- tripzilch 1y ago> There's a user expectation that photo20.jpg comes after photo3.jpg 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.
- zaptheimpaler 1y agoI just tried it on Mac, its sorted in the order you listed. Extending it a bit, the order is: photo1 photo01 photo001 photo0001 photo2 So the shorter representation of the same number comes first. It does make intuitive sense to me.
- throwaway808081 1y agoBut did it show as a list or an ordered collection of folders? And the second time you opened the folder did it rearrange into a haphazard scattering with items off the edge of the window?
- AdieuToLogic 1y ago> I just tried it on Mac, its sorted in the order you listed. Extending it a bit, the order is: > 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&sektion=0&manpath=FreeBSD+14.3-RELEASE+and+Ports&arch=default&format=html https://man.freebsd.org/cgi/man.cgi?query=ascii&apropos=0&se...
- xigoi 1y agoWith ASCII lexicographic ordering, photo01 would come before photo1.
- AdieuToLogic 1y ago> With ASCII lexicographic ordering, photo01 would come before photo1. 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 photo2
- Avshalom 1y ago1 and 0 aren't even in the alphabet so in "alphabetical order" I still wouldn't know a prior how that's sorted. I guess? photo.jpg photo[nine].jpg photos.jpg photos[zero][one].jpg
- deleted 1y ago[deleted]
- derriz 1y ago> The sort rules are simple In considering the simplicity of the rule, I think you're using a developers perspective here where we automatically classify numbers and have a clear mental model of the separation between value and representation. But I'm not sure how simple it would be to explain to a non-technical user why size_5, size_10 and size_15 are in order but size_0.25, size_0.5 and size_0.75 are out-of-order. > with no major outcry I'm regularly amazed at how little non-developer/technical users complain about strange and confusing behavior.
- deleted 1y ago[deleted]
- mcny 1y ago> I'm regularly amazed at how little non-developer/technical users complain about strange and confusing behavior. It reminds me of the recent article here titled something like "Altoids by the mouthful". We just get used to eating cat poop and we never realize it is not a good idea to eat cat poop, not that we should make it more palatable by chasing the cat poop by chewing Altoids by the mouthful. Edit: for today's lucky ten thousand https://news.ycombinator.com/item?id=45343449 https://news.ycombinator.com/item?id=45343449
- quacked 1y ago> I'm regularly amazed at how little non-developer/technical users complain about strange and confusing behavior. I am a highly technical user that works with a lot of people with traditional engineering degrees but little to no software experience (except as frequent users). The answer here is that they've learned that all computer software is arcane and mysterious, and so they just accept that there will be strange patterns they have to pick up on, and that's their role as a user. They don't complain about strange and confusing behavior because they treat all the behavior as strange and confusing.
- throwaway2037 1y ago> traditional engineering degrees What does that mean? What disciplines? I cannot believe that all junior graduates in engineering disciplines in the 2020s are not doing some programming, even if just writing macros in a CAD program.