Live data from Hacker News

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

sebastiano.tronto.net

181–190 of 385 posts

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

#181
post #175

ls sorts filenames strictly lexicographically, comparing character by character, so e.g. "055436307" is compared as the characters "0", "5", "5", etc. so it sorts before "121134" because "0" is less than "1". if all compared characters match and one string ends, the shorter one comes first. Symbols like _ are just more characters, and their position relative to digits depends on the locale’s collation table. Google D…

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.

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

#182
post #141

In Total Commander, there is a function in the options to sort strict by numerical char code. It will sort those files correctly. Unfortunately, it will also sort "10.txt" before "2.txt". --- In all file managers, I miss an API point where one can give a userdefined sorting function for the file and folder list.

What do you mean by "Unfortunately"? This appears to be the only correct conclusion from the algorithm you selected, you can't eat the cake and have it too. Regarding your second point, that's not really what a graphical file manager is for, I think. At this point (likely even earlier) you would be better off just writing a simple script in the scripting language of your choice. (If going for something fancy, you cou…

Paragraph 1: I speak of a sorting method which splits the filename at the boundaries between numbers and non-numbers, and sorts by the parts of the resulting tuple, the numbers naturally (10 comes after 2) and the rest by numerical char code.

Paragraph 2: I am not sure what you mean here with writing a script. The graphical file manager shall sort its file list using the sorting function I hand over to it.

"That's not really what a graphical file manager is for". Says who? Every software which has a plugin system does that, why should a file manager not?

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

#183

I agree with Microsoft/Google/KDE's order. The author's situation is extremely rare, and the situation where someone wants "10" to be before "9" is far more common. Moreover, desktops don't label this sorting "alphabetical" (E: and it would really be "lexicographic"*), they label it "by name" (an informal criteria), so technically they're not lying. > I miss the time when computers did what you told them to, instead…

> I agree with Microsoft/Google/KDE's order. The author's situation is extremely rare...

Even if that were a valid reason for making it the default behavior, the real issue is they don't even give you the option to have the lexically correct sort order. They just decided to give you something that's not accurate and that's all you get.

A trend which is frustratingly, increasingly common.

It's trivial to allow customization behind menus. But we rarely get that anymore. Especially for sandboxes devices like phones.

It's a giant middle finger to users who want to actually use their devices as a tool, instead of simply a portal for more sales and marketing.

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

#184
post #150

Earlier quoted context omitted.

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.

You don’t let every decision to the user, you make good defaults, but leave the option to override to the user! And thousands isn’t scary as long as groups/tags/search work, so what’s ridiculous about empowering the user?

Increasing the number of different possible combinations of settings your software can be running with by a factor of one nonillion is not a choice I’d make if I wanted to have any confidence in its reliability and security.

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

#185
Earlier this year I submitted a bug to VSCode about sorting Playwright tests in the alphabetical-and-numerical order that VSCode favours, after Playwright told me it was a VSCode issue.

Some people rushed to fix this as I'd done some diving into the issue and presented the relevant information and code, so now VSCode's Playwright test list uses the same sorting mechanism as the rest of VSCode.

Sadly, the underlying Playwright does not receive that order from VSCode so it still actually runs sequentially-numbered tests in strict alphabetical order. :(

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

#186
post #50
post #35

> Well, apparently all these operating systems have decided that no, users are too dumb and they cannot possibly understand what alphabetical order means. So when you ask them to sort your files alphabetically, they don’t. Instead, they decide that if some piece of the file name is a number, the real numerical value must be used. Well, no. You don't actually ask them to sort in alphabetical order. You ask them to sor…

> And they choose the interpretation that (per their reasoning, and possibly some actual data) seems most likely to correspond to what the user wants. Yes, that make sense, but the problem is that this interpretation changed in the last 10 (15? 20?) years. It used to be that "by name" meant "by name, il alphabetical / lexicographical order" in pretty much every file manager.

Reminds me of https://xkcd.com/1172/

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

#187

Earlier quoted context omitted.

It’s not being presented as an alphabetical sort, though. The author assumed that sorting by name meant an alphabetical sort, but that’s not how it’s labeled.

In fairness, sorting by name has, for many years, been an alphabetic sort. Doing a mixed alpha/numeric sort is a relatively new thing.

[deleted]

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

#188
post #156

Earlier quoted context omitted.

Yes but not every single one of them

Obviously. All I'm saying is that this particular decision ought not to have been taken from the user. Real alphabetical order is not an unreasonable thing to want.

“Real alphabetical ordering” is incredibly nonspecific. It’s underspecified even for ASCII-US, but essentially meaningless for those of us in 2025 who need to handle Unicode.

How do capital letters sort relative to lowercase letters? How do letters sort relative to digits? How do you consider code points that can correspond to different letters in different lettering systems with different ordering? How do you handle diacritics? Do you want the behaviour to be stable through Unicode normalization? Should it differ based on the character encoding? Should different representations of the same character, such as blackboard lettering or circled numbers, be sorted with other representations of the same character or grouped separately?

You can come up answers for these questions, but there’s no unambiguously correct option. The least subjective option is sorting based on encoded byte representation (if that is even specified), but that is not “alphabetical” and would not be intuitive to most users.

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

#189
post #156

Earlier quoted context omitted.

Obviously. All I'm saying is that this particular decision ought not to have been taken from the user. Real alphabetical order is not an unreasonable thing to want.

“Real alphabetical ordering” is incredibly nonspecific. It’s underspecified even for ASCII-US, but essentially meaningless for those of us in 2025 who need to handle Unicode. How do capital letters sort relative to lowercase letters? How do letters sort relative to digits? How do you consider code points that can correspond to different letters in different lettering systems with different ordering? How do you handle…

The issue at hand is how numbers are sorted. That has nothing to do with unicode.

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

#190
post #136

Earlier quoted context omitted.

Then `budget_100.csv` comes by and now you need to rename 99 files.

It’s been about two thousand years since the number of months in a year has been increased. I don’t think we’re getting 88 new ones anytime soon.

> It’s been about two thousand years since the number of months in a year has been increased.

What? What are you thinking of? The number of months in a year is always 12 or 13 in any calendar system because they start by reflecting the moon. If you mean the Christian calendar, it was fixed at 12 months to the year well over 2000 years ago. If you mean any calendar, it's probably been more like one year since the number of months in a year has been increased. 12 lunar months falls short of a solar year by about 11 days, so any given lunar calendar will generate an extra month about every three years, and there are lots of different lunar calendars.

(For example, the Chinese calendar occasionally repeats full months in order to keep the month of the year lined up with the season. Whenever this happens, there will be 13 months in the year, of which two share the same name.)

Post reply on HN