! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Name sorting is wrong
Status:
RESOLVED: MOVED

Comments

Description Massimo Burcheri 2014-02-05 09:56:29 CET
The sorting for these folder names for column "name" is different from $(ls -l) but more like $(ls -l).

pd="test";mkdir -p $pd/2012_foo $pd/201205_foo $pd/201312_foo $pd/20100321_foo $pd/20120114_foo

Please change the default because this is confusing that numbers are not sorted as expected or make it configurable in the preferences.
Comment 1 Marco van Hulten 2018-08-11 20:17:58 CEST
I experience the same problem in Thunar 1.6.6:

```
$ ls -1
19980102
2003
20030102
```

but the listing in Thunar is thus:

```
2003
19980102
20030102
```

I use ISO 8601 dates, but maybe that's a moot point.  The main problem is that this is not what I expect.  I cannot find anything about sorting in thunar(1) or the online manual (except for `sc-case-sensitive`).
Comment 2 Marco van Hulten 2018-08-11 20:56:59 CEST
Massimo, you wrote '$(ls -l)' twice.  What do you mean?

Furthermore, I found out that all the file managers I tried, pcmanfm, caya, vifm and ranger, have the same behaviour as thunar.

Is there a common library used that implements a sorting algorithm?

Is there some sort of standard for sorting?
Comment 3 Andre Miranda editbugs 2018-11-20 02:09:31 CET
Sorting is determined by LC_COLLATE[1], try:
thunar -q
LC_COLLATE=c thunar

Let me know if that helps.

https://wiki.archlinux.org/index.php/locale#LC_COLLATE:_collation
Comment 4 Massimo Burcheri 2018-11-20 09:06:28 CET
Hi all, thanks for your interest in a 4 years old bug. Playing around with the ls options I was able to reproduce the Thunar sorting with "-v     natural sort of (version) numbers within text". What I meant in 2014 is this:

My expected sorting:
$ ls -1
20100321_foo
20120114_foo
201205_foo
2012_foo
201312_foo

How Thunar does the sorting:
$ ls -1v
2012_foo
201205_foo
201312_foo
20100321_foo
20120114_foo

No, LC_COLLATE=c did not solve it. Are you able to reproduce the sorting?
Comment 5 Andre Miranda editbugs 2018-11-21 14:01:51 CET
Indeed, LC_COLLATE=C (uppercase C, sorry for my typo) did not help, I remember it was useful for other sort issues, but in this case.

Searching about this, I found that users are not happy with Thunar in this sense:
https://unix.stackexchange.com/questions/10581/is-it-possible-to-make-thunar-sort-by-ascii-order
https://forums.linuxmint.com/viewtopic.php?t=213844

Taking a look at the source, it seems the revelent function is thunar_file_compare_by_name. It uses ThunarFile's collate_key and collate_key_nocase, both generated by g_utf8_collate_key_for_filename.
The odd thing about it is that ":" is prepended to filenames:
:::2012_foo
:::::201312_foo
:::::201205_foo
:::::::20120114_foo
:::::::20100321_foo

Quoting g_utf8_collate_key_for_filename source comments:
> Numbers are handled by prepending to each number d-1 superdigits 
> where d = number of digits in the number and SUPERDIGIT is a 
> character with an integer value higher than any digit (for instance 
> ':'). This ensures that single-digit numbers are sorted before 
> double-digit numbers which in turn are sorted separately from 
> triple-digit numbers, etc. To avoid strange side-effects when 
> sorting strings that already contain SUPERDIGITs, a '\2'
> is also prepended, (...)
> 
> This has the side-effect of sorting numbers before everything else (except
> dots), but this is probably OK.

That function usage was introduced by Bug #7110.
Needs further investigation...
Comment 6 Theo Linkspfeifer editbugs 2019-04-23 21:14:09 CEST
*** Bug 11075 has been marked as a duplicate of this bug. ***
Comment 7 Git Bot editbugs 2020-05-26 23:16:56 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org'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.xfce.org/xfce/thunar/-/issues/68.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #10672

Reported by:
Massimo Burcheri
Reported on: 2014-02-05
Last modified on: 2020-05-26
Duplicates (1):
  • 11075 Sort by name doesn't actually sort by name

People

Assignee:
Jannis Pohlmann
CC List:
4 users

Version

Attachments

Additional information