home | list info | list archive | date index | thread index

Re: file managers sorting files by name in wrong order

  • Subject: Re: file managers sorting files by name in wrong order
  • From: Nash JC - NCF <nashjc [ at ] ncf [ dot ] ca>
  • Date: Mon, 30 Jun 2025 16:50:39 -0400
Given that I started this thread, and now Alexander Schwinn on Gitlab XFCE project
has found what he thinks is the cause, and is seeking both a workaround and upstream
fix. Problem apparently arises in glib somewhere, which then gets used in various
file managers. Quoting:



Alexander Schwinn commented:

Thank you! I can reproduce the difference to ls -rtl via thunar master

Here is a simplified reproducer:

mkdir test
touch test/194P
touch test/196A
touch test/20P

ls  test
194P  196A  20P

thunar: 196A 194P 20P

thunar_file_compare_by_name uses collated strings to compare filenames, which is done by utf8_collate_key_for_filename.

I think at least for glib based file managers (nautilus, nemo, caja, thunar, pcmanfm) the reason for the weird result is some "automatic smartness": https://gitlab.gnome.org/GNOME/glib/-/issues/1344#note_1652000

    In a nutshell, what the filename sorting does is to break the names into segments that are either words or numbers, and compare the words alphabetically, and the numbers numerically. That is why leading zeros are ignored.

So it numerically compares 196, 194 and 20 and sorts the files in that order. And it looks like it's desired like that by glib 🙁

So actually not a thunar issue. Beast either comment your concrete use-case on the existing issue, or create a new one. I will close this issue.

(I once wanted to provide a fix for it, see comments below the issue, though I did not have the time to further look into it)

Since there is a constant stream of complaints regarding that weird utf8_collate_key_for_filename call (#68 (closed), #1015 (closed)), I will open a dedicated thunar issue, to possibly implement a workaround, so that people can choose between "automatic smartness" and "plain sorting".

Anyway, I'll stick to Double Commander or Krusader or mc or command line for now, but will
watch to see if there are fixes in a while.

Cheers, John Nash






On 2025-06-30 15:07, Eric Marceau via linux wrote:
As I said in my earlier e-mail, I think the filename sort logic is skewed.

                     |<<< behaviour reflects sub-string cutoff for number sort logic
                     |
     200410    PeterFrohn95thBirthday02withFamily.jpg 19460904PeterFrohnwedding01.jpg
     19460904    PeterFrohnwedding02.jpg
     19460904    PeterFrohnwedding03.jpg
     19460904    PeterFrohnwedding04.jpg
     19460926    AlphonseFrohnmarriesReneev.Seters01.jpg
     19460926    AlphonseFrohnmarriesReneev.Seters02.jpg
     19460926    AlphonseFrohnmarriesReneev.Seters03.jpg
     19460926    AlphonseFrohnmarriesReneev.Seters.jpg

200410  < 19460904

🙁


On 2025-06-29 21:00, Nash JC - NCF via linux wrote:
Indeed. Worth a watch.

However, I've still no idea why the files

19460904PeterFrohnwedding01.jpg
19460904PeterFrohnwedding02.jpg
19460904PeterFrohnwedding03.jpg
19460904PeterFrohnwedding04.jpg
19460926AlphonseFrohnmarriesReneev.Seters01.jpg
19460926AlphonseFrohnmarriesReneev.Seters02.jpg
19460926AlphonseFrohnmarriesReneev.Seters03.jpg
19460926AlphonseFrohnmarriesReneev.Seters.jpg

sort after 200410PeterFrohn95thBirthday02withFamily.jpg

in a number of file managers. I'm guessing something like Beattie is presenting.

Erics suggestion that the preferences might be adjustable doesn't seem to offer
any help. I'm of the opinion that the presentation order counts as a bug unless
someone can offer a clear reason (and presumably a workaround). Fortunately,
Double Commander does a nice job!

Cheers, JN


On 2025-06-29 18:18, Dianne Skoll via linux wrote:
On Sun, 29 Jun 2025 14:41:36 -0400
Nash JC - NCF via linux <linux [ at ] linux-ottawa [ dot ] org> wrote:

yyyymmdd files seem to be at end in many file managers

Sorting is not as easy as it might seem, nor is plain text. This video
by Dylan Beattie is long, but IMO worth watching...

https://www.youtube.com/watch?v=gd5uJ7Nlvvo

Regards,

Dianne.

To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org



To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org



To unsubscribe send a blank message to linux+unsubscribe [ at ] linux-ottawa [ dot ] org
To get help send a blank message to linux+help [ at ] linux-ottawa [ dot ] org
To visit the archives: https://lists.linux-ottawa.org