Sorting by name doesn't work well with digits or special chars

Bug #322271 reported by Stefan Kranich on 2009-01-28
This bug affects 9 people
Affects Status Importance Assigned to Milestone
nautilus (Ubuntu)

Bug Description

Binary package hint: nautilus

On my local disk there is a folder with the following contents:

stefan@ubuntu:~/Dokumente/*/*/*/FLASCHEN_15cm$ ls

I did not include the full path for legal reasons, since it includes names of my customers and brand names. Instead of these, I put * to indicate another subdirectory.

However, when I display this folder in nautilus sorting alphabetically by file name, the resulting order is:


ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 8.10
ExecutablePath: /usr/bin/nautilus
NonfreeKernelModules: ath_hal
Package: nautilus 1:2.24.1-0ubuntu1
SourcePackage: nautilus
Uname: Linux 2.6.27-9-generic i686

Stefan Kranich (philomath) wrote :
Pedro Villavicencio (pedro) wrote :

Thanks for the report, that looks like bug ; which is known upstream, linking the report, thanks.

Changed in nautilus:
assignee: nobody → desktop-bugs
importance: Undecided → Low
status: New → Triaged
Changed in nautilus:
status: Unknown → New

Hi, The gnome bugzilla report is exactly what I'm seeing too.

Linux 2.6.31-21-generic #59-Ubuntu SMP Wed Mar 24 07:28:56 UTC 2010 i686 GNU/Linux

/etc/debian_version squeeze/sid

Ubuntu 9.10 fully updated as of 2010-04-27

The gnome bugzilla report is from 2006 and still "unconfirmed". Is there something that we (i.e. normal users) can do to speed things up ?

Changed in nautilus:
status: New → Confirmed
Grizzly (sven-witterstein) wrote :

Just my 2 cents (same as in gnome-bugzilla 355152)

Cheap, general solution:
- Make an option available in Gconf to change between "ascii" "natural" (=the
current with respect to numbers that are NOT prefixed with "0" ) and
"dos/win-Style" ( prefixes with . in front of the rest, folders separated")

Better solution:
- offer a per-directory config option in addition.
Reason: on my "linux" files, I can live perfectly happy with "natural" sort
order though it "feels" sometimes "weird" and "buggy" - but I do have to mount
a lot of stuff created under windumb - so "win-style" Order should be default
for ntfs-partitions and be selectable for all those dirs from my co-workers
that have all the "!" "__" "_" etc. prefixing to put important stuff, such as
"_main.cpp" on top of a source dir.

It would be so nice to find a solution that offers - thoug hidden in gconf -
choice over the flame war going on here..

Grizzly (sven-witterstein) wrote :

I personally think the reason is "natural sort order" does:
a) not interpret the german "," decimal separator as such
b) not even aussume fractal base 10 - Numbers to be in a filename
c) therefore, it interprets the number as integer, starting after the "," - so it sees
   something mor like 2-dim vector in this filename, putting the <1l bottles before the >=1l bottles,
  and then intepreting the numbers after the "," as "second index", thus sorting
  2 - 5 - 33

I think this is a good example why "naturally" sorting will never work perfectly, because no tool will ever know if you try to provide tuples or german-style fractals in this filename (even if you mess with the locale - how shall nautilus know if the filename has the same locale "in mind" than itself (the given filenames could be created by a german who sends them to an english speaker with a "."-aware locale on his system. On windows, I would name the files
0,20l-mw 0,33l-mw, 0,50l-mw 0,50l-mw 1,00l-ew-pet 1,50l-ew-pet
meaning, I would put "-" or "_" as seperator between parts AND use a constant amount of chars for each file to get a "column" adjusted view of those - and probably, with constanting the amount, even nautilus would sort decently. I am basically suffering that nautilus ignores the "_" "!" prefixing...

The more I think about it, sorting order would be something a good filesystem should record for each directory and this info should even be passed into eg. 7z or zipfiles all the way, so it is retained when going to someone else. Should file a brainstorm thing here - anybody know if zfs has such options yet?

Changed in nautilus:
importance: Unknown → Medium
Embridioum (embridioum) wrote :

I have the same issues but with folders named only with letters.

In my music folder I get "Nightingale" before "Night In Gales" and "Darkane" before "Dark Funeral".

Linux ced-desktop 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:24:35 UTC 2011 i686 GNU/Linux

Here's what I'm seeing right now:



Please raise the importance of this bug to "critical". It's embarrassing!

Changed in nautilus (Ubuntu):
assignee: Ubuntu Desktop Bugs (desktop-bugs) → nobody
summary: - When sorting alphabetically by file name, 0,5LMW is displayed before
- 0,33LMW
+ Sorting by name doesn't work with digits
summary: - Sorting by name doesn't work with digits
+ Sorting by name doesn't work with digits or special chars
summary: - Sorting by name doesn't work with digits or special chars
+ Sorting by name doesn't work well with digits or special chars
Simon Arlott ( wrote :

The Gnome developers appear to be unwilling to fix this after nearly 8 years. I've attached an example of the issue where it is clear that the sort order is wrong, even for proponents of natural sort ordering.

It can be fixed for Nautlius by changing g_utf8_collate_key_for_filename() to g_utf8_collate_key() nautilus-3.10.1/libnautilus-private/nautilus-file.c but this only affects Nautilus windows. File dialogs still use the wrong sort order.

In glib, g_utf8_collate_key_for_filename() is broken for anything with leading zeros (it sorts 2009.1 before 2009.05) so it doesn't even get natural ordering correct.

The sort order of g_utf8_collate_key_for_filename() is too aggressive in splitting up filenames into separately ordered components, which makes it inconsistent with user expectations for highly structured filenames.

Some sort of desktop-wide "use natural sort order" setting is required to allow the behaviour to be adjusted. An environment setting for glib would do (although the change wouldn't be effective immediately).

hergo (hergo-pad) wrote :

You can track a bug request for glib in
and you can find a partial hack at

Grizzly (sven-witterstein) wrote :

Well, nice to see something's going on. The sort just sucks. Why not AT LEAST provide the option to chose between plain ascii-codepage-utf-8-number-in-the-charmap-style sort and this broken natural sort?

Tomas Petricek (tpetricek) wrote :

I simply don't believe this is a design choice:
a a.txt
aa a.txt
a b.txt
k a.txt
k b.txt
kk a.txt

There should be at least an option for the simple alphabetical ordering.
Also, I believe the priority should be higher since listing files is the main function of a file browser...

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.