Flaw with some File Managers alphabetically sorting files correctly

My writing here concerns a flaw discovered in the majority of file managers that are available thru Linux distributions. The flaw is a problem with alphabetic sorting of files within a directory, some files are not sorted correctly. This problem most often occurs with; Thunar, Nemo, File Manager and PCManFM. I have noticed a trend where in the file name the first space between words starts this flaw of scrambling the appropriate letter in alphabetical order based on type of file format.
I have included this example;


Notice how the 3G1_ files have been separated (scattered) out of alphabetical order. In some situations where hundreds of files exist within a directory (folder) they for some reason appear further away from their correct location within the file directory.
This flaw does not occur when using Dolphin in a Linux operating system or Windows Explorer.
Here is an example viewing the same Directory (Folder);

Why is this flaw occurring? Maybe this problem could be corrected somehow, if so I cannot find any way of adjusting anything within the configuration or user preference menu options of the file managers where this problem is occurring. Hopefully bringing this to attention may start action to correct this flaw by people involved with skills and experience to solve the problem and make the script or programming changes necessary.

If you look at the ASCII tables, the numerical value of the character is usually what determines sorting order, and most sort in order, 1st character, 2nd character, 3rd character, etc. The hex codes are the relevant values.

To us it may seem out of order, but looking at the ascii values that can be explained.

For example a space is ascii 20 which comes before all letters, numbers, and special characters. Caps come before lower case letters, numbers come before all alpha characters, etc.

I guess you wanted to link to this sub page:

Because your link just shows the extended ascii set.

Added nautilus, nemo, pcmanfm, thunar

I dont see the issue here?

  1. Numbers
  2. Letters

Also note that pcmanfm is less maintained than pcmanfmqt, which is part of LXQt

No I did not/ This image is what I see.


Though what I linked does show lookuptables.com as the source.

There is not one sort order. The “sort” man page tells:

*** WARNING *** The locale specified by the environment affects sort
order. Set LC_ALL=C to get the traditional sort order that uses native
byte values.

The traditional sort order without any lexicographic rules, just order by ascii byte values, is probably what you want, because it takes spaces into account.
Try: “LC_ALL=C pcmanfm”

Under Mate desktop, this will not work with caja, because another caja is already maintaining the desktop folder. The second one will be launched from the first one missing the LC_ALL=C.

1 Like

Thanks for this information did not realize that alpha-numeric sorting had variations, thought this process had a universal one standard procedure. Then it is my ignorance about the nuts and bolts details that lead me to believe there may be a flaw. I apologize for the inconvenience, thought I might have found something that brought to the attention of people that are experts could help improve things.

The reason such detail is important involves my web site that I hand coded. Each page (250 in all) is located with all of it’s files with alpha-numeric identification. Some longer than others yet working on each page is so much easier when using a file manager that keeps them together, such as Dolphin in Linux and Explorer in Windows.
As I posted a small segment above the first number describes one of 5 total sections of the web site, followed by an alpha letter that has subsections and further on through the first four characters.
I find it difficult running through this web site directory of over 3,800 files when the organization of all the sections is not kept in order. For some reason Nemo, Nautilus, PCManFM, and Thunar do not keep them in order, every section has the same pattern of scattering some of the files for each page as I showed a small part of a few pages. Thanks for your time and consideration.

Thanks for this information, I do recall years ago running across this stuff yet have forgotten about it over the years.

Another thanks for this alternative version.

1 Like

I was not aware of this too, only knew some magic from MySQL database called “collation”.
Dolphin has an option to configure sort. Default is “Natural”, which takes also numbers into account, preventing Pict2 coming behind Pict199. Apparently, this natural sorting handles the spaces better for you. I had the impression that the LxQT variant of pcmanfm does the same, may be because KDE and LxQT share the Qt libraries, offering the “QCollator” class.
With “numericmode= on” and “ignorepunctuation=off”, it should do the work for Dolphin.

1 Like

You can be more specific and set

LC_COLLATE=C.UTF-8

in /etc/locale.conf. Then you don’t modify any other locale settings you might want. The word “collate” is just another word for “sort order”.