Live data from Hacker News

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

sebastiano.tronto.net

51–60 of 385 posts

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

#53
TLDR: the author found out about natural ordering [0], i.e. treating a sequence of digits as a number while sorting.

Usually preferable, except when not. Just like distinguishing between upper- and lowercase letters, and other misery.

[0] https://en.wikipedia.org/wiki/Natural_sort_order

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

#55
post #42

I think the algorithm is probably incorrect. A number starting with 0 should be treated lexically not numerically. Otherwise you have a situation where img_1_01.jpg and img_01_1.jpg does not have a complete ordering.

> Otherwise you have a situation where img_1_01.jpg and img_01_1.jpg does not have a complete ordering.

(Good) "natural sort" implementations generally have ways of handling ties like this. It's similar to the problem of case-insensitive sort over case sensitive sets.

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

#58

I got used to naming files/folders with leading zeros when I want them to be sorted alphabetically (for example payslips/invoices, etc). But I'm a tech guy, I know what does "alphabetically" mean in the tech world. And it probably is not what common folks mean when they think "alphabetically" outside the tech world. Edit: in fact, if I recall correctly, the proper term for this kind of sort (the one OP wants) is alph…

shameless plug (though I don't get a cent out of this, of course): https://blog.vslira.net/2025/03/a-neat-approach-for-sortable...

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

#59

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…

The file sorting isn’t something relegated to niche users because of the prevalence of tv episode file name sorting (eg S01e01) and it has necessitated the leading zeroes to make it work properly with “alphabetical sorting”.

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

#60

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'm not sure I agree. I think I could be convinced if there was a unique and universal representation for numeric values using characters.

But we have so many textual representations of numeric values that I'm assuming the "mind-reading" goodness only works for a small subset. And the subset will be somewhat intuitive for developers but unlikely to be so for non-technical people.

For example, does the order handle numbers with fractions (decimal points)? If yes, does it require a at least one leading digit (zero)? Does a.12345 come before or after a.345?

Does it handle thousand separators? What about international thousand and decimal separators (e.g. Euro-style . for thousand separation and , for decimal separation).

Does it handle scientific notation?

If the answer is no to any of these questions, it's likely to lead to surprise/confusion.

It's like a feature request that initially sounds reasonable and useful but once you explore the requirements in detail you realize there are too many edge cases to be able to meet the request in a non-brittle way.

Post reply on HN