this post was submitted on 24 Apr 2025
204 points (97.2% liked)
Comic Strips
17771 readers
1480 users here now
Comic Strips is a community for those who love comic stories.
The rules are simple:
- The post can be a single image, an image gallery, or a link to a specific comic hosted on another site (the author's website, for instance).
- The comic must be a complete story.
- If it is an external link, it must be to a specific story, not to the root of the site.
- You may post comics from others or your own.
- If you are posting a comic of your own, a maximum of one per week is allowed (I know, your comics are great, but this rule helps avoid spam).
- The comic can be in any language, but if it's not in English, OP must include an English translation in the post's 'body' field (note: you don't need to select a specific language when posting a comic).
- Politeness.
- Adult content is not allowed. This community aims to be fun for people of all ages.
Web of links
- !linuxmemes@lemmy.world: "I use Arch btw"
- !memes@lemmy.world: memes (you don't say!)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It's sorting correctly.
11 comes after 1.
The problem is the data needs to be fixed. 01, 02, 03...
It's not sorting correctly. Right above the listing it specifically says "(sorting by #)".
If it says it is sorting by number, but then it sorts alphabetically, then it isn't sorting correctly.
Problem is it can't sort by number of there are text values in file name. "11" is a number. "11." is not. :) Fun with computers!
Both "11" and "11." are strings, because the context is listing filenames. Filenames are not numbers. They are strings. If you sort filenames by number, you are asking the computer to interpret the string as having a number inside it. At worst, it might interpret "11" as an integer and "11." as a floating point number, because that syntax is often used to specify a floating point number in programming. But even then, it could still sort them correctly.
I don't mean to start an argument, but as a professional programmer, there are just some things that I know.
Are you intentionally ignoring that the actual names of the files are "11. EpisodeEleven.mp3"? There's whitespaces and a bunch of letters there.
I'm also a professional programmer, and assuming that sorting by numbers code would try to grab the first block of strings until the first whitespace is a big assumption I would not make. I'd say that after trying to convert everything but the extension to a number for sorting it failed so it defaulted to string sorting for everything else.
You explaining that you would only do a numerical sort when the basename of the filename is entirely a number, as if your logical sense translates into a good user experience, is exactly why companies have to hire UX designers instead of just programmers.
If you have Windows 10, I suggest that you play around with filenames with numbers in file explorer and see how they're sorted. Your intuition does not match the average user's expectations in this circumstance.
I know it doesn't, I was countering your logic of "I'm a professional programmer" as if the correct interaction would be obvious to a programmer. The intended interaction requires extra thought and to be more through than the obvious one, as you have described.
In alphabetical sorting 11 comes before 2 For the same reason AA is before B.
Not just someone. It's the default when numbers are in text strings, they are treated as text, not as numerical values.
To account for numbers in text strings in any text listing system, requires quite a bit of extra work when programming it.
So the joke is that computers are pretty dumb in this regard, and they need a lot of help to do it right.
Basic sorting is always like this, the joke is that way too many people still number things badly. Alphanumerically sorting variable-length numbers without normalizing the number of digits will always result in situations like 02 < 1 < 109 < 11 < 2
Yeah! In general, Normalization refers to adjusting values measured on different scales to a common scale.
Consider 1 and 10. The value of the first digit of both numbers is 1, so a scale-invariant numerical sort sees both numbers as coming before 2.
Normalizing both numbers to a two digit scale gives us 01 and 10, which sort as expected with 02.
Indeed! That kind of scale-sensitive value-based sort requires the data to be invariant in other ways, though. For example, "Episode Three" has 13 charachters, so it would come after "Episode Four" which only has 12 and therefore must be smaller.
Turns out that sorting things is way more complicated than it seems. The wikipedia page on sorting algorithms in computer science lists 37 different ways to sort numbers and it is far from an exhaustive list.
It definitely feels like that!
Have a classic joke on the subject:
Most software errors are edge cases, like when a program receives an input from a user that the programmer didn't account for.
The software tester is "fuzzing" the input function of the bar by throwing a bunch of weird inputs at it, like jumping through the door rather than walking or ordering absurd, negative, or non-numerical quantities of beer. This is a common way of testing software to make sure it won't crash and burn if unexpected things happen.
Satisfied that the inputs for entering the bar and ordering beer are working properly, the bar opens, and the very first customer still manages to crash it by asking something entirely unrelated to ordering beer.
Wow. Reply guy party.
The joke is that computers work this way, and it's aggravating.
Being computer illiterate makes you angry, I guess?
No, I did not mean you.
I found it especially overblown since I ran into a very similar issue recently. I actually laughed at myself when I saw the mangled list and fixed the names (it helped that the list was something I generated with a script and adding leading zeroes was a simple matter).
Filenames are text, not numbers, so 11 comes before 2. So does 111, 101, etc. Anything starting with 1 is before 2.
In order to sort "properly", you have to name your files properly.
00
01
02
up to...
99
If you have more than 100 files in the same folder, the you have to go back through and re-name them:
000
001
002
... 099
100
Oh no this isn't it, this is extremely basic. As a programmer you will encounter way way more complex logic problems, so logic problems become 2nd nature. And it can be frustrating when "normies" don't understand what appear to a programmer to be a matter of pretty simple logic thinking.
It's so nice we have people like you, that allows us to feel superior, even if we are inferior in every other way imaginable. 👍
Because it's the same? Or because it's very different?
My wife was a professional musician for a few years.
PS:
Do you get this joke?
The wife sends the man for shopping and asks him to buy 1 liter milk and if they have eggs buy 12.
When he comes home, she looks at him astonished, why did you buy 12 liters of milk?
Because they had eggs he responds.
It's also why stuff like this exists:
https://www.bulkrenameutility.co.uk/
A Perl program to convert the number of digits in the first numeric field that appears in a list of filenames.
source
Looks something like:
it doesn't, it reconciles that 02 comes before 11
yeah
It's sorted alphabetically. All the numbers that start with "1" come first, then all the numbers that start with "2", regardless of how long the actual number is.