Open JChristensen opened 5 years ago
I tried half a dozen other file managers and they all exhibit this behavior. I started playing around with simpler filenames: I can definitely see some order here, it's just not what I would expect. There could very well be a good reason for it also, I haven't had a chance to dig any deeper yet.
Both nautilus and nemo use this function to generate keys to compare: https://developer.gnome.org/glib/stable/glib-Unicode-Manipulation.html#g-utf8-collate-key-for-filename.
Interestingly, if I use simple g_utf8_collate_key ()
instead of the filename version, the sort order seems how I would expect it to be:
back to your original file list, it now becomes:
I'll have to look at the source for those functions and see what's different. It seems there's more at work than the documentation implies. I may consider making this something configurable, as I'm pretty sure there are a few other bug reports of incorrect sorts.
Thanks
@mtwebster, thanks very much for the feedback and I'm glad you were able to reproduce the issue. I was working on a project that generated several hundred files whose names were md5 hashes. This is not particularly causing me any hardship but it seemed strange enough that I thought I would report it.
I did check other issues before raising this one and saw some with sorting issues but they all seemed to involve special characters (underlines, etc.), so this seemed at least somewhat different. With all my filenames being the same length and made up of normal alphanumeric characters, I thought it odd that a name that started with "2" sorted before one that started with "0".
Thanks again! We are really enjoying Linux Mint. You all are doing a super job. 19.1 is an excellent release. 18.3 was working so well for me that I thought I'd wait longer to upgrade, but 19.1 seems even better.
The 0 is ignored basically. It tries to identify the relevant number. For instance, in 028e
, it's neither 0
, nor 2
which is relevant, it's 28
.
I think the main idea is to order things the way people would expect, neither alphabetically nor numerically, but logically, with 10
being higher than 9
and with 90
being higher than 10
.
I see what's going on now. It's probably working as designed. Any string of digits (0-9) is replaced by its value for sorting purposes. https://en.wikipedia.org/wiki/Natural_sort_order
I suppose this is desirable in some or even many situations. In my case with filenames that are hexadecimal values, the results seemed nonsensical.
Personally I'd almost always want just a simple straight alphabetical order like ls
, so I'd definitely welcome an option in Nemo's preferences to choose the desired sorting algorithm.
Issue Nemo does not sort files by name correctly.
Steps to reproduce Run script below to create a directory and some files. Start Nemo, navigate to folder created by script. Click on Name heading to sort by filename.
Expected behaviour Nemo sort order is the same as that of the
ls
command.Other information Screen shots of Nemo and
ls
showing different sort order.Script