> ... it would be great if I could just trust that every device will understand numbers.
Strings are not numbers, even if some part of their content "looks like a number."
> 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".
Problem is, this is your preference for a specific situation. Which may not be another person's preference in the same situation nor yours in a different situation.
So what are programs to do?
Display strings in a consistent, documented, manner. Which is lexicographical ordering in all cases lacking meta-data to indicate otherwise.
IMO, "Treat any sequence of digits as a number for the purpose of sorting" is consistent. I'm not sure if it's documented—I've never needed to look up the documentation—but if it's not, the developers could certainly fix that.
> this is your preference for a specific situation.
Sure, but we generally make decisions based on which situations we think will be most common. I think having ten or more things (screenshots, audio samples, whatever) named "Thing 1" – "Thing 10" in a folder is extremely common. And if Thing 10 comes before 9, it's really annoying!
Let's say I have a directory of 32 numbered files. Under the author's preferred sorting method, they'll get displayed:
1
10
11
12
13
14
15
16
17
18
19
2
20
21
22
23
24
25
26
27
28
29
3
31
32
4
5
6
7
8
9
If I download a folder with files like this, I basically have to pause whatever I'm doing and edit the files to have leading zeroes before I can make sense of what I'm looking at. 1
2
9
10
11
So I guess you also want things sorted like 1.1
1.2
2
9
9.9
And also 1
1.1
1.10
1.2
1.10.1
So when you're done defining whatever crazy rules you think up, how do I pause whatever and edit the filenames to get them back into lexicographical order?You can massage lexicographical to meet your needs. I can't massage your arbitrary rules to meet my needs.
Are you sure about that?
So how do you suggest handling hexadecimal numbers?
Or octal numbers?
What about binary numbers?
What about file names with portions of a date and/or time?
How is a program supposed to know any of the above?
> Let's say I have a directory of 32 numbered files.Assuming any of the filesystems I am aware of is in use, those names are strings having one or two characters. They are not "numbered files."
It just happens to be the most logical way to sort for computers too, as long as humans are involved in the usage of the data.
> those names are strings having one or two characters. They are not "numbered files."
Yes they are! In this context, a number is an idea, not a data type. Strings are capable of containing numbers.
Op was taking about changing the rule to something more intuitive, in such case it would s'en natural that decimal numbers are used.
And what about very long strings of digits in the filenames - so long that they are too long for even the longest available numerical representation? In some apps, they are converted to floating point...
How about decimal numbers, are they strings or still numbers?
How about version numbers with multiple dots?
How about decimal numbers of a different locale, e.g. you list the folder from a remote machine with filenames of a different locale?
The problem with such semi-consistent schemes is that they are still guess-work, they may make some cases better for some people, but other cases practically unusable because the system doesn't have sufficient information to handle all scenarios consistently.
Irrelevant and intentionally obtuse. Filenames can't be anything but strings - there's literally no way to mark part of a filename as "this is an integer", so the idea that "strings are not numbers" is ridiculous because the only way to encode numbers (which people constantly want to encode) is as part of a string - which means that parts of filenames are numbers, because that's exactly how people use them.
> Problem is, this is your preference for a specific situation. Which may not be another person's preference in the same situation nor yours in a different situation.
> So what are programs to do?
> Display strings in a consistent, documented, manner. Which is lexicographical ordering in all cases lacking meta-data to indicate otherwise.
These do not follow from each other.
First, the assertion that "peoples' preferences are different, so we shouldn't pick an overwhelmingly common preference" is laughably false. The vast majority of computer users (which happen to not be people on HN) prefer "sort numbers by number rather than by UTF-8 value", so that's simply the correct way to sort.
Second, even regardless of the above, there's nothing preventing a "by name" sorting from being consistent and documented.
Either way, this line of reasoning is just wrong.