• @Buffalox@lemmy.world
        link
        fedilink
        5
        edit-2
        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.

      • knightly the Sneptaur
        link
        fedilink
        4
        edit-2
        2 months 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

          • knightly the Sneptaur
            link
            fedilink
            3
            edit-2
            2 months 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.

              • knightly the Sneptaur
                link
                fedilink
                12 months 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.

                  • knightly the Sneptaur
                    link
                    fedilink
                    3
                    edit-2
                    2 months ago

                    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.

          • @Klear@sh.itjust.works
            link
            fedilink
            22 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).