With "ls" the following files are sorted as I want as:

026  046  048  08f  28f  46a

but in file manager (I have tried nautilus, nemo and pcmanfm) they are sorted as:

08f  026  28f  046  46a  048

At this article says you can affect sort order in file browser using:

export LC_COLLATE=C;   nemo&

But I tried this and the sort order is still the same - numerically not alphabetical.

Is there away of getting any file manager to sort as ls does by some option in preferences or by setting a variable such as LC_COLLATE?


Extra information on why files are sorted numerically for those interested :

At bugs.launchpad.net

the reason given for sorting numerically goes something like a user expects the following files to be ordered numerically like:

8     9   10   11  101

and not alphabetically like:

10  101   11    8    9

and where as I can see this point:

  1. If files are ordered alphabetically, then you simply need to pad files with a zero, to make them ordered numerically (easy to script using printf "%03d" ), but there is nothing you can pad files that are ordered numerically to order them alphabetically.
  2. It is not obvious how the files ordered numerically at the top of this post are sorted - I spent 30 mins creating various files and could not figure out how they were being sorted and had to resort to Google to work it out, where as it is a lot easier to workout that "numbered" files like 10,101,11,8,9 are ordered alphabetically.

  3. Even AFTER I knew files were ordered numerically it still took a while to understand, and hard to locate the files I wanted (I have over 70 files to look through) - point in case is the comment by "muru" who says they couldn't see how 08f comes before 026 numerically and they have a reputation of over 100,000, so is clearly very intelligent. In contrast, when you know files are ordered alphabetically it is easy to understand how the "numbered" files are sorted and easy to locate them.

I don't mind the default being to sort numerically in a file browser as long as there is an option to change default to sort alphabetically, so surely there is a file manager that has this option or that uses "LC_COLLATE"

  • Do your file browsers have sorting set to by name? I don't see how 08f comes before 026 alphabetically or numerically. – muru Mar 3 '18 at 17:37
  • Every file browser I have tried here seems to ignore the preceeding 0 when sorting. Very interesting. I have been looking all over and nothing is showing how to sort these by the preceeding 0's. – Terrance Mar 3 '18 at 18:02
  • Yes File Browsers have sorting set by name and 08f comes before 026 numerically as 8 comes before 26 - try it out in your file browser and if it orders "correctly" (as ls does), then please let me know the name of your file browser. – Mike Bounds Mar 4 '18 at 8:33
  • 1
    So far I have found XFE file manager does list them the correct way. sudo apt install xfe – Terrance Mar 5 '18 at 14:46
  • 1
    Midnight Commander or mc is one that lists them correctly as well. It is run directly from a terminal though. Not really a GUI app. You might just have to keep trying file managers until you can find something that fits your needs 100%. It does sound as though most of the developers of these applications have followed the same settings of how things are sorted. Beyond that, I am out of ideas as you would have to get the source for any of the browsers you wanted to use and modify it for the sorting and I wouldn't know the first place to look for that. – Terrance Mar 6 '18 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.