diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-09-28 14:52:58 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-09-28 14:52:58 +0200 |
| commit | f3fa55e4b9d06e477f2392fb56f86fe46d48d9fa (patch) | |
| tree | 51c06d8cfa936349880b6ccf6824f09241b0d28e | |
| parent | 0d6075c7aa34c668767db41bf49d6f145c39552b (diff) | |
| parent | abef2ef3771392e52e85714b1eea1de10851e5ef (diff) | |
| download | sebastiano.tronto.net-f3fa55e4b9d06e477f2392fb56f86fe46d48d9fa.tar.gz sebastiano.tronto.net-f3fa55e4b9d06e477f2392fb56f86fe46d48d9fa.zip | |
Merge branch 'master' into altavia2
| -rw-r--r-- | src/blog/2025-09-28-alphabetic-order/alphabetic-order.md | 102 | ||||
| -rw-r--r-- | src/blog/2025-09-28-alphabetic-order/dolphin.png | bin | 0 -> 123212 bytes | |||
| -rw-r--r-- | src/blog/2025-09-28-alphabetic-order/drive.png | bin | 0 -> 29700 bytes |
3 files changed, 102 insertions, 0 deletions
diff --git a/src/blog/2025-09-28-alphabetic-order/alphabetic-order.md b/src/blog/2025-09-28-alphabetic-order/alphabetic-order.md new file mode 100644 index 0000000..262a0d8 --- /dev/null +++ b/src/blog/2025-09-28-alphabetic-order/alphabetic-order.md | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | # When I say "alphabetic order", I mean "alphabetic order" | ||
| 2 | |||
| 3 | Last month I have been on a multi-day hike with my dad. Each of us took | ||
| 4 | many pictures, and when we came back we put them all in a shared folder. | ||
| 5 | We both have Android phones, and the naming scheme used for our pictures | ||
| 6 | was the same: `IMG_YYYYMMDD_HHmmss` followed maybe by some other numbers | ||
| 7 | and then a `.jpg`. Here `YYYY` stands for the year, `MM` for month and | ||
| 8 | so on, so that sorting the pictures in alphabetic order is the same as | ||
| 9 | sorting them by date. | ||
| 10 | |||
| 11 | Or so I thought. Strangely, when I looked at the files from my dad's | ||
| 12 | Windows PC, they were not sorted correctly: all the pictures took | ||
| 13 | with my phone came first, followed by all the pictures took by him. | ||
| 14 | I thought this was surely some weird Microsoft bug - after using | ||
| 15 | Windows 11 at work for a while, I would not be surprised if you | ||
| 16 | told me their file explorer can't figure out how to sort strings. | ||
| 17 | |||
| 18 | But then I looked at the same files in a shared Google Drive folder, | ||
| 19 | and again they were in the wrong order: | ||
| 20 | |||
| 21 |  | ||
| 22 | |||
| 23 | As you can see, the picture taken at 5:54 (with my dad's phone) comes | ||
| 24 | before the one taken at 9:20 (also with my dad's phone), but after the | ||
| 25 | one taken at 12:11 (with my phone). | ||
| 26 | |||
| 27 | Weird. Well, maybe Microsoft *and* Google got this wrong. But | ||
| 28 | that seems unlikely. | ||
| 29 | |||
| 30 | Indeed, KDE's Dolphin file manager does the same thing: | ||
| 31 | |||
| 32 |  | ||
| 33 | |||
| 34 | I'll spare you the screenshots, but Gnome and both the file managers | ||
| 35 | that I have on my phone also get the alphabetic order wrong. | ||
| 36 | |||
| 37 | At this point I thought that maybe one of the two phones is using some | ||
| 38 | weird alternative unicode character instead of the underscore `_`. Really, | ||
| 39 | I could not see any other explanation. But nope, this is not it, because | ||
| 40 | the good old `ls` sorts my files correctly: | ||
| 41 | |||
| 42 | ``` | ||
| 43 | $ ls -l | ||
| 44 | |||
| 45 | total 218572 | ||
| 46 | -rw-r--r-- 1 seba seba 1866185 Aug 28 18:51 IMG_20250820_055436307.jpg | ||
| 47 | -rw-r--r-- 1 seba seba 4749899 Aug 28 18:50 IMG_20250820_092016029_HDR.jpg | ||
| 48 | -rw-r--r-- 1 seba seba 6201609 Aug 28 18:52 IMG_20250820_092440966_HDR.jpg | ||
| 49 | -rw-r--r-- 1 seba seba 7694802 Aug 28 18:51 IMG_20250820_092832138_HDR.jpg | ||
| 50 | -rw-r--r-- 1 seba seba 1536520 Aug 20 09:57 IMG_20250820_095716_607.jpg | ||
| 51 | -rw-r--r-- 1 seba seba 1054553 Aug 20 10:38 IMG_20250820_103857_991.jpg | ||
| 52 | -rw-r--r-- 1 seba seba 965353 Aug 20 10:39 IMG_20250820_103903_811.jpg | ||
| 53 | (and so on) | ||
| 54 | ``` | ||
| 55 | |||
| 56 | This was consistent among the couple of Linux distros I use, as well | ||
| 57 | as my OpenBSD server. On the one hand this is good: not *every* single | ||
| 58 | piece of software fucks up something as basic as string sorting. On the | ||
| 59 | other hand, this makes it harder to debug what the fuck is going on with | ||
| 60 | all the other file managers. | ||
| 61 | |||
| 62 | It took me more than a month to figure this one out. Tell me, which | ||
| 63 | file do you think comes first in alphabetic order, `file-9.txt` or | ||
| 64 | `file-10.txt`? | ||
| 65 | |||
| 66 | Of course, the user who named those files probably wants `file-9.txt` to | ||
| 67 | come before `file-10.txt`. But `1` is smaller than `9`, so `file-10.txt` | ||
| 68 | should be first in alphabetic order. Everyone understands that, and | ||
| 69 | soon people learn to put enough leading zeros if they want their files | ||
| 70 | to stay sorted the way they like. | ||
| 71 | |||
| 72 | Well, apparently all these operating systems have decided that no, | ||
| 73 | users are too dumb and they cannot possibly understand what alphabetic | ||
| 74 | order means. So when you ask them to sort your files alphabetically, | ||
| 75 | they don't. Instead, they decide that if some piece of the file name is | ||
| 76 | a number, the real numerical value must be used. | ||
| 77 | |||
| 78 | I don't know when this became the norm, to be honest I have not used a | ||
| 79 | normal graphical file manager in a long time. | ||
| 80 | |||
| 81 | *I know you asked for the files to be sorted in alphabetic order, | ||
| 82 | but you don't want `file-10.txt` to come before `file-9.txt`, do | ||
| 83 | you? No, I know you don't. I am not even going to ask you, your | ||
| 84 | mushy human brain is too small to comprehend the intricacies of | ||
| 85 | such a question. I'll spare you the thinking.* | ||
| 86 | |||
| 87 | So it turns out that my dad's phone wrote the milliseconds in the file | ||
| 88 | name right after the seconds, while mine added an extra underscore to | ||
| 89 | separate them from the seconds. Which in my mind it should not have | ||
| 90 | mattered, because alphabetically they should still have been sorted | ||
| 91 | correctly to the second. But with this "modern" interpretation of the | ||
| 92 | alphabetic order, the files without the extra separator in the name had | ||
| 93 | a much higher number, so they come last. | ||
| 94 | |||
| 95 | Now that I know what the issue is, I can solve it by renaming the files | ||
| 96 | with a consistent scheme. I have also found a setting to fix Dolphin's | ||
| 97 | behavior, but it was very much buried into its many configuration | ||
| 98 | options. And I would rather not have to change this setting in every | ||
| 99 | application I use, assuming they even allow it. | ||
| 100 | |||
| 101 | I miss the time when computers did what you told them to, instead of | ||
| 102 | trying to read your mind. | ||
diff --git a/src/blog/2025-09-28-alphabetic-order/dolphin.png b/src/blog/2025-09-28-alphabetic-order/dolphin.png new file mode 100644 index 0000000..2342445 --- /dev/null +++ b/src/blog/2025-09-28-alphabetic-order/dolphin.png | |||
| Binary files differ | |||
diff --git a/src/blog/2025-09-28-alphabetic-order/drive.png b/src/blog/2025-09-28-alphabetic-order/drive.png new file mode 100644 index 0000000..9bd044e --- /dev/null +++ b/src/blog/2025-09-28-alphabetic-order/drive.png | |||
| Binary files differ | |||
