Sorting files with accents in filename

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

Post Reply
gmb
Junior Member
Junior Member
Posts: 60
Joined: 2009-04-15, 19:42 UTC

Sorting files with accents in filename

Post 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.
User avatar
petermad
Power Member
Power Member
Posts: 14808
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Sorting files with accents in filename

Post 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.ž)
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Sorting files with accents in filename

Post 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.
Author of Total Commander
https://www.ghisler.com
gmb
Junior Member
Junior Member
Posts: 60
Joined: 2009-04-15, 19:42 UTC

Re: Sorting files with accents in filename

Post 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.
User avatar
petermad
Power Member
Power Member
Posts: 14808
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Sorting files with accents in filename

Post 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
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Sorting files with accents in filename

Post 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.
Author of Total Commander
https://www.ghisler.com
Post Reply