• Wren@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    10 hours ago

    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)

      • Wren@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        9 hours ago

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

        • knightly the Sneptaur@pawb.social
          link
          fedilink
          arrow-up
          5
          arrow-down
          1
          ·
          edit-2
          7 hours ago

          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

          • Wren@lemmy.world
            link
            fedilink
            arrow-up
            4
            ·
            9 hours ago

            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?

            • knightly the Sneptaur@pawb.social
              link
              fedilink
              arrow-up
              3
              ·
              edit-2
              7 hours ago

              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.

              • Wren@lemmy.world
                link
                fedilink
                arrow-up
                2
                ·
                9 hours ago

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

                • knightly the Sneptaur@pawb.social
                  link
                  fedilink
                  arrow-up
                  1
                  ·
                  9 hours ago

                  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.

                  • Wren@lemmy.world
                    link
                    fedilink
                    arrow-up
                    3
                    ·
                    8 hours ago

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

        • Buffalox@lemmy.world
          link
          fedilink
          arrow-up
          5
          arrow-down
          1
          ·
          edit-2
          9 hours 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.

    • jordanlund@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      9 hours ago

      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

        • Buffalox@lemmy.world
          link
          fedilink
          arrow-up
          4
          arrow-down
          1
          ·
          9 hours ago

          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.

          • Wren@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            9 hours ago

            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.

            • Buffalox@lemmy.world
              link
              fedilink
              arrow-up
              3
              ·
              9 hours ago

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

                • Buffalox@lemmy.world
                  link
                  fedilink
                  arrow-up
                  3
                  ·
                  8 hours ago

                  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.

                  • Wren@lemmy.world
                    link
                    fedilink
                    arrow-up
                    2
                    ·
                    5 hours ago

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

          • Wren@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            9 hours 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.

          • tal@lemmy.today
            link
            fedilink
            English
            arrow-up
            1
            ·
            8 hours 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
            $
            
    • konalt@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      9 hours 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.

    • Skullgrid@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      9 hours ago

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

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