Live data from Hacker News

When I say “alphabetical order”, I mean “alphabetical order”

sebastiano.tronto.net

351–360 of 385 posts

Re: When I say “alphabetical order”, I mean “alphabetical order”

#351
post #331

Earlier 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.

I consider 八 to be a whole number.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#352
post #295

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…

There is a rule that works for all cases. It's lexicographical sorting. Simple. Consistent. Easy to manipulate to get what you want.

We just discussed a situation where lexicographical sorting doesn’t work. Adding in a rule to treat consecutive digits as one number doesn’t significantly complicate the logic and makes sorting work for a major additional use case. It doesn’t magically fix every case but it fixes a common one with minimal downsides.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#353
post #332

Earlier quoted context omitted.

As I said, the sorting rule won’t always give pleasing results, but it seems to me like a simple and reasonable modification of lexicographic ordering.

It is neither simple, nor reasonable. 1.10, the number, is equivalent to 1.1. It is less than 1.2. You say you want numbers to sort as numbers, but you want 1.10 to be greater than 1.2. Do you consider '1/4' to be a number? Should it come before or after '1/3'? I'm guessing that you don't want to sort one character at a time if you encounter one of [0-9]. Instead, you want to group all consecutive [0-9] as a single s…

It doesn’t work for decimals. It also doesn’t work for pi, or most dates. That’s okay. Supporting those cases would require “reading your mind” / trying to guess what the user wants by applying opaque rules. I certainly don’t want that.

Treating consecutive digits as numbers is a simple modification (I still think it’s quite simple) that is easy to understand and supports 99% of real-world use cases.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#354

Earlier quoted context omitted.

I will add that I'm plenty "smart" enough to understand that "10" comes before "9" in a strictly alphabetical sense, and I still want my file managers to sort "9" before "10". I don't want to put leading zeroes before every all the single digit numbers in my file names. (And then potentially go come back later and add even more leading zeroes once the maximum number reaches three digits.) --- I split all of my audiob…

> I will add that I'm plenty "smart" enough to understand that "10" comes before "9" in a strictly alphabetical sense, and I still want my file managers to sort "9" before "10". Amen. > I split all of my audiobooks into chapters. I use the format "Chapter 01.mp3" (or "Chapter 001.mp3" when there are > 99 chapters) because some (all?) MP3 players are too stupid to sort numbers properly and I want my audiobooks to work…

There’s a couple of reasons I don’t use m4b files:

- A lot of my audiobooks come as mp3, and converting to m4b (which is AAC based) would mean loosing quality.

- Some MP3 players (even those that support AAC) don’t support M4B.

- I want playback to stop automatically at the end of a chapter, unless I actively decide to start the next chapter. (Admittedly, some MP3 players don’t have an option for this anyway and will always start the next track. This annoys me.)

- Even with chapter metadata, I find it difficult to seek through a 10+ hour m4b file. Seeking through a 10 – 60 minute chapter is more manageable. (Of course, this doesn’t always work out; A Memory of Light has a single chapter that’s more than ten hours long. Whatever, I want to split in a way that follows the author’s structure, and Sanderson purposefully chose to write one extremely long chapter.)

I probably sound like I regularly switch between 20+ different models of MP3 player. In fact, I mostly use my computer or iPhone these days; however, I expect my audiobook collection to outlast any one piece of hardware.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#355
This must be why, when I have a folder in Win11 full of files with GUIDs as names, they are never in the order I expect. Windows seems to sort them randomly but there must be some sub-sequence of numbers that it's deciding are the important ones and sorting off those. For me I'd much rather just sort left to right alphabetical.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#356
post #234

FWIW, for Windows Explorer the numerical sort order can be disabled by setting the DWORD value HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\Policies\Explorer\NoStrCmpLogical in the registry to 1.

I honestly thought Explorer was broken and have been looking into 3rd party file browsers for Windows because this has been driving me so nuts. Thank you!

Re: When I say “alphabetical order”, I mean “alphabetical order”

#357

Earlier quoted context omitted.

I think the only problem is that it's a surprise and mystery, particularly because "dumb" alphabetical sort has existed forever. When they "fixed this" for the 99% of regular users cases, they should have made it as separate "smart natural sort" option separate from the "strict alphabetical sort" option (next to date, size, etc). Simple and obvious, rather than surprisingly different from the decades of experience th…

It's not just the one decision though; there are literally thousands, maybe tens of thousands, of these decisions in most software. You want every single one of them to have an option? You want it to support every single combination? At some point, it is ridiculous. Sometimes you just have to decide how your software is going to work and not leave every single decision to the user.

There's such thing as too many options, and there's also such thing as too few. This is one of the important ones. I'd say that macOS, Gnome, and Windows have definitely hidden or removed a lot of important options in the past decade, and despite the modern slickness mesmerizing people into thinking they're easier to use, they're actually harder to use as a result.

(I say this as a professional developer and power-user of all 3 desktops over the past 25 ish years, who also helps non-technical family and friends a few times every year. Some people will be like "oh I'm so bad at computers lol" or "oh this is a piece of junk huh" but really the UI just got dumber in the name of "ease of use", and the expert has to be called in to decipher it.)

Re: When I say “alphabetical order”, I mean “alphabetical order”

#358
post #234

FWIW, for Windows Explorer the numerical sort order can be disabled by setting the DWORD value HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\Policies\Explorer\NoStrCmpLogical in the registry to 1.

I honestly thought Explorer was broken and have been looking into 3rd party file browsers for Windows because this has been driving me so nuts. Thank you!

There’s also the account-specific HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\ NoStrCmpLogical, which I meant to mention, but mixed them up by mistake.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#359
post #132

Earlier quoted context omitted.

> 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

Does 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)…

> Does it matter?

Yes. An algorithm must be unambiguosly specified for all possible inputs.

Re: When I say “alphabetical order”, I mean “alphabetical order”

#360

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/nsstrin... :) [2] https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/...

I 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
Post reply on HN