GNOME Bugzilla – Bug 352237
g_utf8_collate_key_for_filename breaks case ordering
Last modified: 2018-05-24 10:51:37 UTC
For some reason g_utf8_collate_key_for_filename sorts case-different files different. As a test case, use: "Test1.txt", "test2.txt", "test3.txt". g_utf8_collate_key will show them in that order. However, g_utf8_collate_key_for_filename will order them as "test2.txt", "test3.txt", "Test1.txt".
This is a reflection of the fact that the collation rules are typically not "compositional". It (conceptionally) uses several passes and only considers case differences in a later pass. Sorting complete strings yields test1 Test1 test2 Test2 but if you split the numbers off and compare the strings and numbers separately, you get test1 test2 Test1 Test2 because test < Test The only fix here would be to interleave our special handling of numbers and .s with the usual multipass collation algorithm, which is something I'm not really prepared to do...
*** Bug 745664 has been marked as a duplicate of this bug. ***
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/62.