GNOME Bugzilla – Bug 754777
Improve filename sorting by name with digit -- Add flexibility
Last modified: 2018-04-25 15:57:06 UTC
Binary package hint
Problem in glib,
Impact in nautilus, thunar, any popup or window which use g_utf8_collate_key_for_filename
Where is the problem
in g_utf8_collate_key_for_filename Collation API
g_utf8_collate_key_for_filename as in API description, do some interpretation on number. Good goal but have some side effect.
The method is used everywhere to order file like in nautilus.
The problem become when interpreted number describe a date or a float.
And order is different from LS.
Then this method go too far in interpretation.
Example with a directory listing with some dummy file:
ls show something like
001 004 1 A B a b
and for example, nautilus show:
1 001 004 A B a b
Another point of view is with for example photos in directory with name 070804 for 2007-08-04 date and a second directory named 120423 for 2012-04-23 date, second will show before first in nautilus
Nautilus and any other software use g_utf8_collate_key_for_filename due to its name, then I don't ask to change api, but to make it more flexible...
Make an option available through environment variable like GLIB_MAGICNUMBER_COLLATE, true by default, to change between "ascii" and "natural"
This variable will be listen in g_utf8_collate_key_for_filename in a big if, if false then g_utf8_collate_key is called.
By this way, we have the possibility to have an ascii ordering.
316960 328383 338154 398729 435505 605598 609991 619612 621245 631376 633406 638839 654721 681176 700950
+ 30 related bugs opened
P.S.: I made a hack to tempory fix it on my system: https://github.com/heralight/GlibSortFileNameHackLibrary
g_unicode_collate_for_filename does exactly what its documentation says it is supposed to do. I don't think it is a good idea to make low-level library API change behavior in response to random environment variables like this.
All right so everything is good and the 30 bugs on this are ignored because thy are not relevant?
Sorting in nautilus is embarrassing and it doesn't match the open/save file dialog. As here discussed number handling is strange and leading symbols to create "sticky" folders on top of directories do not work.
People complain about this for over 8 years.
A simple solution could be to just add some fine tuning options for the sorting like checkboxes for "ignore leading numbers", "sort case sensitive" and "sort the POSIX way"
*** Bug 759832 has been marked as a duplicate of this bug. ***
Thanks for taking the time to report this.
This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.
*** This bug has been marked as a duplicate of bug 793747 ***