it’s so confusing that the order changes when adding IDENTICAL strings to BOTH filenames. Is this really how it’s supposed to be?

  • slazer2au
    link
    fedilink
    English
    264 months ago

    Humans order by strings, computers order by characters.

  • @folekaule@lemmy.world
    link
    fedilink
    504 months ago

    Yes. The periods are just part of the name like any other letter, so 5 is compared to m, and numbers sort before letters. You can add something like ‘.0’ to make it sort more naturally. Look up an ASCII table to get a feeling for how strings are sorted.

  • @Lysergid@lemmy.ml
    link
    fedilink
    25
    edit-2
    4 months ago

    What you expecting called natural sorting. Mac employed natural sorting back in 90s. What you get is legitimate Alphabetical sorting which used by Linux and Windows. Natural sorting parses tokens in the string and compares them. Alphabetical sorting compares two strings by comparing individual characters at same index (position). Alphabetical sorting is quite common as it simpler to implement (or rather harder to screw up) and yields predictable results

    One of many libraries for Python which implements natural sorting https://github.com/SethMMorton/natsort

  • @xeekei@lemm.ee
    link
    fedilink
    English
    64 months ago

    I’ve always felt like numbers should be ordered after letters. A-Z then 0-9.

  • Papamousse
    link
    fedilink
    34 months ago

    Always been weird, this is why for instance my ll alias is:

    alias ll='LC_COLLATE=C ls -alFh'
    alias ls='ls --color=auto'
    
  • Brewchin
    link
    fedilink
    English
    24 months ago

    I encounter this mostly with manga. (I’ll not rehash what others have said).

    FWIW, and in that use case, I deal with it by renaming x5 to x5.0 so it will sort before x5.5. And then usually put both into an x5 directory and then zip that into a CBZ.