Page 1 of 1

Sorting files with accents in filename

Posted: 2024-02-18, 08:57 UTC
by gmb
There's a problem with sorting files with accents in the filename.
In this example, I'm using the letters č š ž, from Slavic languages using Latin script.

When I go to "Sort active panel" and mark "By Name" -> "Ascending"
files are sorted alphabetically considering accents, like this:

Image: https://postimg.cc/CRX5Nc3F

When I go to "Sort active panel" and mark "By Extension" -> "Ascending"
files are sorted by numeric character code, like this:

Image: https://postimg.cc/SX9stW4c

There's no "Sort method" option in "Configuration", like there is in Total Commander for PC.

Re: Sorting files with accents in filename

Posted: 2024-02-18, 10:31 UTC
by petermad
2gmb

So it is the secondary sorting by name when choosing sort By Extension that is wrong . what about files with the same name but with the different Slavic characters in the extension - are they sorted correctly (file.c, file.č, file.s, file.š, file.z and file.ž)

Re: Sorting files with accents in filename

Posted: 2024-02-19, 09:53 UTC
by ghisler(Author)
Total Commander uses Collections.sort() to sort the file list. This calls "compare" for each pair of file names, which are then compared with a class called Collator. The collator performs locale-specific comparisons.

Total Commander loads the collator as follows:
collator=java.text.Collator.getInstance(Locale.getDefault());
According to the debugger, this uses the RuleBasedCollator class.

So the rules by which the lists are sorted depend on the current default system locale (language settings) of your Android device. If your device is set to English (UK) locale, it will use English rules.

Please check your Android settings what locale is set there.

Re: Sorting files with accents in filename

Posted: 2024-02-19, 11:20 UTC
by gmb
I'm using Total Commander 3.50b3
Xiaomi Redmi 8, MIUI 12.5.2, Android 10

System default language is Croatian, and language in Total Commander is set to Croatian.
If language in Total Commander is set to Czech, results are the same.


When sorting by name, files are sorted in correct alphabetical order ( c č s š z ž ), both by names and by extensions.

When sorting by extensions, files are sorted in correct alphabetical order by extensions ( c č s š z ž ), bur the names are sorted by character code ( c s z č š ž ).

When sorting by size or by time, both names and extensions are sorted by character code ( c s z č š ž ).
All files in the example are the same, with the same content, size and time.


If I change language in Total Commander to English, sorting by extensions, size or time is the same as above.
Sorting by name then uses some strange (and wrong) logic.

Re: Sorting files with accents in filename

Posted: 2024-02-19, 13:14 UTC
by petermad
bur the names are sorted by character code ( c s z č š ž ).

When sorting by size or by time, both names and extensions are sorted by character code ( c s z č š ž ).
All files in the example are the same, with the same content, size and time.


If I change language in Total Commander to English, sorting by extensions, size or time is the same as above.
Sorting by name then uses some strange (and wrong) logic.
AS I suspected - it is the secondary sorting (after sorting by extension, size or date) that is wrong

Re: Sorting files with accents in filename

Posted: 2024-02-20, 08:57 UTC
by ghisler(Author)
You are right, the compare function is comparing the name objects (which would be the text strings) when the result is "equal", e.g. when the extensions are the same. I will compare by name when they are the same.