g_utf8_collate_key_for_filename() corner cases with digits
@20YearsOfGnome
Submitted by Paul Link to original bug (#793747)
Description
Created attachment 368820 Screenshot of Nautilus sorting the test files by name
Moved here from the relevant Nautilus bug: nautilus#264 (closed)
Create some test files as follows:
$ touch 000001000010-0.jpg 000001000010-A.jpg 000001A00010-0.jpg 000003BBF000-0.jpg 00003bA1A000-0.jpg 00003BD22000-0.jpg 0000A4AC3000-0.jpg 000100001 000100001.jpg 000200001
View them at the command line and in Nautilus:
$ ls -1
000001000010-0.jpg
000001000010-A.jpg
000001A00010-0.jpg
000003BBF000-0.jpg
00003bA1A000-0.jpg
00003BD22000-0.jpg
0000A4AC3000-0.jpg
000100001
000100001.jpg
000200001
$ nautilus .
[see attached screenshot]
ls sorts files as one might expect. It is not case sensitive (unless you use a case sensitive locale, e.g. LANG=C), but sorts alphabetically.
Nautilus sorts the files in a bizarre order, regardless of which locale is used. Weird behaviours include:
- Longer but otherwise equal filenames sort before shorter ones
- Sometimes ignores runs of zeros, but not punctuation
- Seems to detect runs of digits and push them to the end
The actual behaviour is very complex and difficult to predict, though it must follow some internal logic. The end result is that files don't sort in any reasonable order. This impacts several Gnome applications, such as Eye of Gnome and Nautilus. Other applications, like Transmission, respect locale.
Attachment 368820, "Screenshot of Nautilus sorting the test files by name":
Version: 2.54.x