TC4A 3.0b13: Numbers are sorted in alphabetic order

Support for Android version of Total Commander

Moderators: sheep, Hacker, Stefan2, white

Post Reply
User avatar
Usher
Power Member
Power Member
Posts: 891
Joined: 2011-03-11, 10:11 UTC

TC4A 3.0b13: Numbers are sorted in alphabetic order

Post by *Usher »

When using sort by name, files with numbered names are ordered in alphabetic order rather than numerical. For example 1, 2, 3, 10, 11, 12, 100, 101, 1000 are ordered as 1, 10, 100, 1000, 101, 11, 12, 2, 3. It's annoying for longer file lists.
Tested on Android 8. Is the sort order system dependent or possible to improve?
Regards from Poland
Andrzej P. Wozniak
rudolfm
Junior Member
Junior Member
Posts: 4
Joined: 2019-11-14, 21:11 UTC

Re: TC4A 3.0b13: Numbers are sorted in alphabetic order

Post by *rudolfm »

This is normal with computers in general. All file managers do this.
Name your files 0001,0002,0010,0020 if you want then sorted.
With dates, use 2019-12-30 and not 30-12-2019.

Look at the download server of mozilla Firefox for Android, you will see the same thing:
https://ftp.mozilla.org/pub/mobile/releases/
User avatar
Usher
Power Member
Power Member
Posts: 891
Joined: 2011-03-11, 10:11 UTC

Re: TC4A 3.0b13: Numbers are sorted in alphabetic order

Post by *Usher »

rudolfm wrote:
2019-12-28, 02:11 UTC
This is normal with computers in general. All file managers do this.
Any good file manager can provide more refined sort order than simple command line tools. Even Windows Explorer can. Do you use Total Commander for Windows?
rudolfm wrote:
2019-12-28, 02:11 UTC
Look at the download server of mozilla Firefox for Android, you will see the same thing: https://ftp.mozilla.org/pub/mobile/releases/
It's a table generated by a web server using some server-side (command line) tools. Real FTP site looks like that: ftp://ftp.icm.edu.pl/pub/mozilla/firefox/releases/ and it also provides results generated by the server-side tools.

If you go to ftp://ftp.icm.edu.pl/pub/ you will see typical Unix-like sort order (UPPERCASE before lowercase) - it's system dependent sort order. Firefox does NOT re-sort names to use letter-case independent sort.
Regards from Poland
Andrzej P. Wozniak
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 40058
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: TC4A 3.0b13: Numbers are sorted in alphabetic order

Post by *ghisler(Author) »

Sadly there is no sort function in Java to sort with this so called "natural sorting" method. I could do my own sort function, but it would be many orders of magnitude slower because java byte code is much slower than hard coded machine code used now.
Author of Total Commander
http://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 891
Joined: 2011-03-11, 10:11 UTC

Re: TC4A 3.0b13: Numbers are sorted in alphabetic order

Post by *Usher »

2ghisler(Author)
Thanks for explanations. Some apk developers seems to ignore that fact - they use numbers without leading zeros for filenames and provide misordered lists in their apps.
Regards from Poland
Andrzej P. Wozniak
Post Reply