Linux Locale And File Manager Collate 2016-05-19
Recently I found myself trying a bunch of Linux file managers and getting ready to rant about thunar. Turns out the problem was actually Linux, and it seems to be present in a lot of file managers. I got through trying most of the GUI file managers listed in Arch's wiki before I found someone who had an actual answer to the problem. I tried a few more file managers after that, but frankly didn't try very hard.
The symptom is that Thunar ignores non-alpha-numeric characters when sorting. I am also under the impression that if a file name begins with a number, Thunar evaluates all numeric characters (up to the first non-number) as if they were a single character. So, for example if you had files named "21 jump street", "666 fuzzy bunnies", and "1984 was an okay album", Thunar would sort them like this by default:
21 jump street
666 fuzzy bunnies
1984 was an okay album
Now clearly, when sorting "alphabetically", 1984 should be first... but Thunar floats it down because 1984 is higher than both 21 and 666. At the right you can see another example of poor sorting. It would make sense to me that "abe lincoln's pineapple" should be the third file listed, but Thunar ignores the spaces in "a good day to die" which floats it to the position below "abe". Why anyone would think that this is the best possible default behaviour is completely beyond me.
Eventually, during my search for a replacement file manager I came across bug #436524 which made me realize that the problem is in fact not Thunar. The problem is the way Linux is interpreting my locale, specifically my LC_COLLATE. After issuing the command
I had Thunar sorting like this:
Now to make this change permanent (well, at least to enable it for subsequent logins) I had to add the export command shown above to my ~/.config/openbox/environment as described in the Autostart page at the OpenBox wiki. If you use a fancier window manager and/or desktop environment your config requirements may be different, but the idea is the same... get Linux to use a more appropriate locale to COLLATE, and your file manager won't exhibit ridiculous sorting behaviour.