Live data from Hacker News

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

sebastiano.tronto.net

301–310 of 385 posts

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

#301
There are quite a few more rules for sorting that can be applied - it's not just numbers, and numbers don't always work the way you describe.

There is "Dictionary Order", "Phone book order", and a few other standards. (Dictionary order is not lexicographic order, even if the two are now commonly conflated).

A simple rule that most still know is a book titled "The Book", should be sorted under "Book, The".

They have variations on how special characters sort, how abbreviations are handled, and even have differences in numbers. For example, in phone book order, "21st Century" sorts under “Twenty-first”, not "21".

And, of course, non-English languages add all sorts of other rules.

This tends to get ignored these days, as lexical sorts are so much easier to implement, that people forget there are other, preferred options.

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

#302
post #10
post #2

https://www.unicode.org/reports/tr10/#Contextual_Sensitivity : “There are additional complications in certain languages, where the comparison is context sensitive and depends on more than just single characters compared directly against one another, […] Numbers. A customization may be desired to allow sorting numbers in numeric order. If strings including numbers are merely sorted alphabetically, the string “A-10” co…

But -10 is smaller than -2, right?

I know you jest, but this just further demonstrates why Natural Sorting is complicated and might not be the best default choice.

my_photos_at_-3c

my_photos_at_-10c

Do users want smaller numbers first, or do they want them in counting order, away from zero?

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

#303

I am surprised how many people are comfortable calling sorting numbers alphabetical sorting (including TFA). In true alphabetical sorting, sorting numbers is undefined behaviour. Both of these sorting methods are valid extensions of alphabetical sorting, and which you prefer is just that: a preference. So actually when he says ‘alphabetical order’, he does not, in fact, mean ‘alphabetical order’.

I personally call it "ASCII sorting", or "UTF-8 sorting".

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

#305
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.

Sure, but if in this case the number would have only indicated the month you have an issue way earlier than 100 actually, you already have an issue on month 13 when you would go back got 01 and now you are overriding the old one.

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

#306

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…

Most of the time, as a regular user, I agree with having smarter ordering. And smarter all features for what its worth. Except when it doesn't work because of some corner case. In which case the "smart feature" becomes a kind of a leaky abstraction - now as a user I have to figure out how the machine works, so that I can trick into doing what I need.

Give the user an option: have both "by name" lexicographic ordering, make it default by all means, but also provide a way to switch to an alphabetical order one for power users. Same applies to other features.

It is disappointing that apps and even some Linux Desktops today take the flexibility away from users, in the name of usability. By all means, I like and benefit from all the smart features, and I want them and will keep the on by default, but leave me an option to do the simpler, dumber and more predictable things too, for the case when I need to fallback to it.

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

#307
post #136

Earlier quoted context omitted.

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.

Sure, but if in this case the number would have only indicated the month you have an issue way earlier than 100 actually, you already have an issue on month 13 when you would go back got 01 and now you are overriding the old one.

Presumably there is a separate directory for every year.

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

#308
post #54

> But nope, this is not it, because the good old ls sorts my files correctly Did the author try "ls -v"? It would probably give the exact same order these file managers used.

ls -l does not sort, so I think the author is just very confused?

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

#309
post #295

Earlier quoted context omitted.

Would you sort 1.10 1.2 or 1.2 1.10 ? I would not know how an OS treats those if we do not assume mindreading vs proper lexicographic order. Why would we need to substitute precision with vagueness for something that simply taking care of proper naming would suffice?

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…

I was with you until this point, but 1.2 is bigger than 1.10, because 1.2 is a shortened version of writing 1.20 _unless_ you explicitely want these to be version numbers or something like that. The normal expectation would be to treat numbers as, well, mathematical numbers, and not SemVer, especially if we only have one decimal point, don't you think?

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

#310
post #295

Earlier quoted context omitted.

Would you sort 1.10 1.2 or 1.2 1.10 ? I would not know how an OS treats those if we do not assume mindreading vs proper lexicographic order. Why would we need to substitute precision with vagueness for something that simply taking care of proper naming would suffice?

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…

> 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 locales, where the decimal point is a comma and thousands-separator is a dot. Should the locale then also be considered by that system? Also when listing the folder of a remote-system with a different locale?

What about dates, should that system attempt to sort entries with multiple date-formats (yyyy-mm-dd, dd-mm-yyyy, dd-MMM-yyyy,...)?

The topic is far more complex than this narrow example. If we expect such a system to alter its sorting based on some data format interpretation, there is a risk of misinterpretation which might make the whole list unusable...

Post reply on HN