6 ms·
> Display strings in a consistent, documented, manner. IMO, "Treat any sequence of digits as a number for the purpose of sorting" is consistent. I'm not sure i
by Wowfunhappy 1y ago
> Display strings in a consistent, documented, manner.
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.
- AdieuToLogic 1y ago> IMO, "Treat any sequence of digits as a number for the purpose of sorting" is consistent. 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."
- ewidar 1y agoI am not sure any of the points you raised change anything to the OP's point, do they? Op was taking about changing the rule to something more intuitive, in such case it would s'en natural that decimal numbers are used.
- Moru 1y agoSorting dates: This is why there is an international standard of having YYYY-MM-DD hh:mm:ss in the order we have it. We got to learn this in school in the 80-ies because sorting paper documents would be more logical and easier to find stuff. So way before most people got computerized. 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.
- rickdeckard 1y ago> Sorting dates: This is why there is an international standard of having YYYY-MM-DD hh:mm:ss in the order we have it. That would be great, but this ISO is just one of the standards, and there are still regional standards as well. And that's still ignoring the end-user. In Europe for example, humans might create filenames with date in format dd.mm, e.g. "Report 25.01.xls" A system attempting to sort this intelligently would likely assume this is a decimal number, as it has zero context for it. It's just slightly worse than the lack of consistent UTC-usage of systems, with the mixed attempts to correct data to local timezone (or not) depending on application...
- Wowfunhappy 1y agoOkay, I'll refine the rule to "Treat any sequence of digits as a base 10 whole number for the purpose of sorting". I still think this is quite clear. (Frankly, I also think the original definition is quite clear unless you're purposefully trying to misinterpret it.) > 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.
- Skeime 1y agoI generally agree that treating substrings that are numbers as numbers is a good default for most users in most situations. However, for hex numbers this simply won't give good results because some of them will just happen to not contain any of the digits A to F and be treated as base-10 numbers by the heuristic while others will include these digits and be sorted differently. (So, a having a strict lexicographic mode as an alternative in file managers would be nice.)
- mnw21cam 1y agoOctal or binary numbers are going to be fine, but it'll totally and confusingly mess up hexadecimal numbers.
- freeopinion 1y agoDo I understand that you want these to be sorted like this? 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.
- foldr 1y agoYour examples don’t need any extra rules to be sorted correctly. The basic idea is that any sequence of digits is treated for sorting as if it were a single character. On my iPhone, your examples are sorted as expected.
- freehorse 1y agoWould 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?
- deleted 1y ago[deleted]
- foldr 1y agoAh 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 all cases.
- cyxxon 1y agoI 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?
- rickdeckard 1y ago> "Treat any sequence of digits as a number for the purpose of sorting" is consistent. 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.
- witrak 1y agoYour concept appears to have coherence until you consider that numbers are not necessarily expressed in decimal notation. What about hexadecimal numbers in filenames? Should they be sorted your way? 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...