File names not sorted properly

I’m trying to migrate from my old Debian laptop to my new Librem 15 running PureOS, but I’m hitting a bit of a snag when it comes to file-sorting.

On my Debian machine, files are sorted correctly, character by character. For example, a directory’s contents would be displayed in this order:


However, on my new PureOS system, consecutive digits are being lumped together, treated as a single character, and sorted by numeric value. For example, the files above would instead be displayed in this order:


This doesn’t look like a big deal at first, aside from being incredibly annoying, but I have several files of which I know the first several digits, but don’t remember the full numeric value of. When sorted properly, I can find them by those first few characters, but when sorted in this bizarre way, it makes it very difficult to locate them. How do I get PureOS to display files in a sorted-by-character way instead of this sorted-by-numeric-value way that it does by default?

File names are sorted properly then, 11 is greater than 2.

For my works like that in Debian and Ubuntu, maybe it’s something to do with the Desktop environment and it’s version.

“11” may be greater than “2”, but “0x11” is not greater than “0x2b”, and the file manager still gets the order wrong. Besides, compressing digits into a single entity to sort instead of sorting per character is not sorting properly. After all, file names are *STRINGS*, not numeric values, even if they include digits in them.

As for desktop environments, I read somewhere (I forget where) that the PureOS-specific applications are designed to work with GNOME and don’t really work with other file managers. If that’s true, I’m stuck with GNOME and need to fix its file sorting instead of switching to a desktop environment that already sorts files properly, such as LXDE.

Or is this untrue? Do PureOS’s system-specific applications and security features work just fine on other desktop environments?

1 Like

How are you sorting? Are you viewing files in the file manager? If so, you can click on the upper right hand corner on the downward arrow which will show you a number of ways to sort. Perhaps changing the sort method helps?

Yeah, I’m trying to get the file manager to display the files in a sorted order.

The downward arrow you mentioned provides several options for sorting files like you said, though only two of those sort by file name. One sorts alphabetically, while the other sorts anti-alphabetically. They’re direct opposites though, as one would expect. They both cluster consecutive numeric characters and treat them as a single character, sorting by numeric value of the integer you’d get from converting all those characters into a numeric value. One just puts high values first instead of last.

I know what you mean, it can be hassle to rename files by adding zeros before file’s name, like this
1 to 01 for ten or more files
If I have a hundred or more files then
1 or 01 to 001
So on to keep listing of files in order from top to bottom.

Not only is is a hassle, but it’s sometimes not feasible. I have over a hundred files in one such directory. But also, renaming the files forces me to relearn the file names. It doesn’t fix the problem of not being able to find the files by the names I already know the beginnings of due to this improper sorting.

I know it doesn’t address your sorting concern, but until that is addressed you may find that typing the first few numbers onto the keyboard after you have opened the relevant directory will jump straight to the file with those numbers in the order typed regardless of sorting method. Not a solution, but a potential work around.

With that said, I’ve dealt with systems that sort via both methods and my personal preference is ones that sort by value instead of by character. I do not agree that either is “correct” but rather that they are each different. Most modern systems I encounter treat number sequences as number values as that is how the majority of humans read them.

Normally, I agree, neither way id “correct”. But when the system starts forcing the one I can’t stand on me, with no obvious way to turn the “feature” off, that’s when I get salty and start calling that method incorrect. This sorting method irks me even more than case-insensitivity does, too. At least case-insensitivity makes sense on some level. This really doesn’t, when you think about the fact that filenames are strings and strings don’t get sorted this way.

I’ve found on this new system, I’ve had to give up a lot of the workflow tools I’d used every day, which is frustrating, though most of it I’m willing to forego. Basic filename sorting is a bit too important for me to give up though. However, that search trick with the typing the beginning of the file name seems to work even better on this system than my last. On my last, it jumped to the files that begin that way, which wouldn’t have helped much if those files were split up, and this sorting method splits them up. On this system though, it makes the non-matching files completely disappear from the list, which not only makes search feature actually work despite the badly-sorted files, but would make the search feature more convenient even once we get the files sorted better. This is the first difference I’ve seen that feels like an improvement over what I’d had, instead of a loss, so thank you for showing me that.

I do need to get my files sorted properly though. It’s one of probably only three features that I absolutely can’t stand to live without. (The other two being a fully-free system, as I’d been on Debian which is also free; and the ability to block outgoing traffic from applications that don’t want to play nicely with the proxy, which can be done with iptables.) I’m willing to change nearly my entire workflow to give this new operating system a try, but I can’t give up by-character filename sorting in the file manager.

I use Cinnamon on PureOS so my file manager is Nemo, I also have Nautilus installed which I suspect is the default. When using “ls” via the command line the files are sorted as you desire which implies the file managers I have installed are not sorting as the base system does but converting it to sort numeric strings as numbers.

After a quick search of “Debian file managers” I found manager you might want to try whichever file manager is the default for the desktop environment you were using on your Debian install.

Alternatively you may want to try each of these to find out if maybe there is a file manager that gives you the sort of your old file manager and the search of your new file manager.

The problem is that the desktop environments seem to often be hopelessly entangled with their file managers, so even when you choose a different file manager, the one you don’t want to use gets used anyway in some contexts. Maybe GNOME (PureOS’s default) doesn’t have that problem? I don’t have a whole lot of experience with GNOME, as I find it a bit cumbersome to work with, so this might simply not be a problem GNOME has. I’ll try changing out the file manager and see if GNOME handles that better than Xfce does. (I had to give up Xfce a while back because it’s hopelessly entangled with Thunar, which exhibits this same aggravating behaviour.)

The ls command is an excellent example of file-sorting done right. That’s exactly the type of sorting I expect from my file manager.

I tried setting a different default file manager, but I can’t seem to figure out how to do that properly. There seems to be no graphical way to do it, unless I missed something. I added a file called “~/.local/share/applications/defaults.list”, which reads the following:


I think that’s the way you have to do it in GNOME? That didn’t work though. Next, I tried running these two commands:

yst@taylor:~$ xdg-mime default inode/directory pcmanfm.desktop
yst@taylor:~$ xdg-mime default pcmanfm.desktop x-directory/normal

That didn’t work either. When I try to open a directory from, say, PureBrowser, it still opens Nautilus. I even tried rebooting the machine, which honestly shouldn’t even be necessary, but that didn’t update the default file manager either. How do I switch the default file manager?

@jeremiah would likely have a better answer for you on changing the default file manager and what impact that would have. Personally I’d try removing all file managers except the one I wanted, though I have no idea what impact that might have and it may not be a good idea…

I tried that too. Other things depend on that file manager though, including the desktop environment itself, so the package manager would have removed those things too had I not aborted the process.

1 Like

I was experimenting today, trying again to fix this issue, and found that the file manager is also treating file names as case insensitive. Any idea how to turn that feature off as well? If I can’t find a fix for these problems, I’m going to have to wipe the system and install Debian, which I know can sort files properly. I really don’t want to have to do that. I’d like to give PureOS a try. But I can’t do that if I can’t even get PureOS to perform even the most basic of tasks, such as sort files properly.

My school term is going to start soon too, and it’d be great if I could get migrated to my Librem laptop before it starts.

What do you mean with case insensitive? Can you create a folder named “Folder” and other one named “folder”?

Maybe it’s something to do with the locales? check if you are using the same in both systems.

Both “Folder” and “folder” can exist, but “aa” gets sorted before “Az”, even though upper-case letters are earlier in the unicode table. As for locale, I’ve got the same locale on both systems, the difference is that on PureOS, I’m stuck on GNOME dealing with GNOME’s problems. As mentioned previously in the topic, the Purism team chooses to support only GNOME with some of their features (though further reading tells me KDE is also supported). On Debian, I’m free to use desktops that don’t fight me and actually sort files properly when told to, such as LXDE. Someone recommended switching file managers in GNOME, but also as mentioned before, I can’t find a way to set the file manager GNOME uses, and no one seems to have the answer on how to do that either.

It’s worth mentioning too that $LC_COLLATE is set to “C”, and GNOME is ignoring that, too.

Okay, I figured out how to fix the case insensitivity issue. The setting for that is in a menu I’ve now managed to lose again, so I’m not sure how to fix it next time. I still can’t find any setting for fixing the numeric sorting problems though. It’s been nearly a week of not being able to migrate to this laptop, and I’m running out of time before the term starts. I’m really starting to think giving up on PureOS might be my only option. As I said before, I’d love to give this system a try, but I can’t do that if I can’t even get it to sort my files properly. This is such a basic use case, it seems bizarre that the system doesn’t seem to be able to handle it.

I am surprised that there isn’t an option to override this behaviour (which is intentional). I was amused to see on the internet people complaining about other file managers that they aren’t capable of sorting this way. You can please some of the people some of the time …

Do you have programming skills? Don’t like the way an open source program works? Download the source and make it work the way you want it.

Maybe try a different file manager.

Unfortunately that review doesn’t tell you about sorting capability, so you would have to investigate each one that you choose.

Just for a laugh, FileZilla does normal sorting and so you could use that to give you a graphical list of local files even if you never FTP anything anywhere.

I was unclear whether there is a specific use case where file naming and file sorting interact badly for you (hence you could use an alternative file manager just for that use case) or this is a generic problem across your whole usage.

As I’ve said several times now, I’d *LOVE* to switch to a better file manager. I even already have one in mind. However, I can’t figure out how to configure GNOME to use my choice in file managers. It just keeps using Nautilus whether I like it or not. It’s worth mentioning that my ~/.config/mimeapps.list file contains the following three lines:


GNOME doesn’t seem to care, and uses Nautilus anyway. And for good measure, I’ve rebooted several times since adding those lines, and it hasn’t fixed the problem. GNOME won’t switch to using PCManFM.

Is it Gnome or PureBrowser?

When I open a directory in Firefox it does not appear to use nautilus at all. Instead it uses its own internal file browser apparently, which, as it happens, does a normal sort (1,11,2) - in fact, totally normal: directories interspersed with files, uppercase before lowercase.