this post was submitted on 24 Apr 2025
208 points (100.0% liked)

Comic Strips

17636 readers
2132 users here now

Comic Strips is a community for those who love comic stories.

The rules are simple:

Web of links

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 6 points 2 months ago* (last edited 2 months ago) (4 children)

Fair point, but how does it reconcile that 11 and 12 comes before 2?

(Admittedly, I know nothing at all about this stuff. I’m a music major and I went all in on that, so I’m genuinely curious)

[–] [email protected] 9 points 2 months ago (1 children)

In alphabetical sorting 11 comes before 2 For the same reason AA is before B.

[–] [email protected] 4 points 2 months ago (5 children)

So that’s the joke then? That someone chose to alphabetically sort numbers?

[–] [email protected] 6 points 2 months ago* (last edited 2 months ago)

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.

[–] [email protected] 5 points 2 months ago* (last edited 2 months ago) (2 children)

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

[–] [email protected] 4 points 2 months ago (1 children)

I’m assuming that normalizing digits is similar to normalizing audio? Where you take the numbers and assigning them all a blanket set of instructions?

Normalization in mixing audio essentially takes a track and adjusts the volume of the track’s peaks to keep them from clipping the volume threshold.

Is it like this?

[–] [email protected] 3 points 2 months ago* (last edited 2 months ago) (1 children)

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.

[–] [email protected] 2 points 2 months ago (1 children)

Ahhh. So you have automated processes that will handle it as well. Just plug in the ranges and it does its thing.

[–] [email protected] 1 points 2 months ago (1 children)

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.

[–] [email protected] 3 points 2 months ago (1 children)

Seems like programming isn’t too dissimilar to giving a child instructions.

[–] [email protected] 3 points 2 months ago* (last edited 2 months ago) (1 children)

It definitely feels like that!

Have a classic joke on the subject:

A software tester walks into a bar.

Runs into a bar.

Crawls into a bar.

Dances into a bar.

Flies into a bar.

Jumps into a bar.

And orders a beer.

2 beers.

0 beers.

99999999 beers.

a lizard in a beer glass.

-1 beer.

"qwertyuiop" beers.

Testing complete.

A real customer walks into the bar and asks where the bathroom is.

The bar goes up in flames.

[–] [email protected] 2 points 2 months ago (1 children)

I really wish I knew what the joke was. 🥺

[–] [email protected] 2 points 2 months ago* (last edited 2 months ago) (1 children)

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.

[–] [email protected] 3 points 2 months ago

Ahhh! I get it. Okay, yeah. That’s funny. 😄

[–] [email protected] 3 points 2 months ago

Wow. Reply guy party.

[–] [email protected] 1 points 2 months ago (1 children)

Being computer illiterate makes you angry, I guess?

[–] [email protected] 1 points 2 months ago* (last edited 2 months ago) (1 children)

Me? Not at all. Unless you meant the comic strip thing, then yeah. I suppose I could see that.

Being bad at a lot of things doesn’t bother me a bit. I’m good at other things. And some of those things, I’m even great at!

[–] [email protected] 2 points 2 months ago

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).

[–] [email protected] 1 points 2 months ago

The joke is that computers work this way, and it's aggravating.

[–] [email protected] 4 points 2 months ago (1 children)

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

[–] [email protected] 7 points 2 months ago (2 children)

I’m starting to understand why programmers are always so angry…

[–] [email protected] 6 points 2 months ago (1 children)

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.

[–] [email protected] 3 points 2 months ago (1 children)

As a “normie” I’d never assume to understand even the most basic of programming. My head hurts to even try and come up with a joke involving the subject.

[–] [email protected] 4 points 2 months ago (1 children)

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. 👍

[–] [email protected] 3 points 2 months ago (1 children)
[–] [email protected] 4 points 2 months ago (1 children)

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.

[–] [email protected] 3 points 2 months ago

I do get that joke, but that’s probably because I’m of the ASD persuasion.

[–] [email protected] 3 points 2 months ago (2 children)
[–] [email protected] 2 points 2 months ago

Ahh. Makes sense that it can be automated. Same as with audio engineering. Though I like to normalize by hand sometimes as automated normalization tends to make a track sound lifeless and dead.

[–] [email protected] 1 points 2 months ago

A Perl program to convert the number of digits in the first numeric field that appears in a list of filenames.

source

#!/usr/bin/perl -w
# numberit.pl
# Converts between number formats (number of leading zeros) in numbers in title names
# Usage: <number of digits> filelist

$digits = shift (@ARGV);

if ($digits > -1)
{
    foreach $oldName (@ARGV)
    {
        $newName = $digitValue = $oldName;

        if ($digitValue =~ m/\//) {
          $digitValue =~ m/^(.*\/[^0-9\/]*)([0-9]+)([^\/]*)$/;
          $prefix = $1;
          $postfix = $3;
          if (!defined($prefix)) {
            $prefix = "";
          }

          $digitFormatted = sprintf("%0${digits}d", $2);

        } else {
          $digitValue =~ m/^([^0-9]*)([0-9]+)([^\/]*)$/;
          $prefix = $1;
          $postfix = $3;
          if (!defined($prefix)) {
            $prefix = "";
          }

          $digitFormatted = sprintf("%0${digits}d", $2);


        }

        if ($digitValue) {
          $newName = $prefix . $digitFormatted . $postfix;
          rename($oldName, $newName);
        }
      }
}

Looks something like:

$ touch a1.mp3
$ touch a2.mp3
$ numberit.pl 3 *
$ ls
a001.mp3  a002.mp3
$ numberit.pl 2 *
$ ls
a01.mp3  a02.mp3
$
[–] [email protected] 3 points 2 months ago

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.

[–] [email protected] 3 points 2 months ago (1 children)

Fair point, but how does it reconcile that 11 and 12 comes before 2?

it doesn't, it reconciles that 02 comes before 11

[–] [email protected] 2 points 2 months ago (1 children)

Ahhh. Because it’s alphabetical? Like how “eleven” comes before “two” alphabetically?