Strange file-sorting-by-name quirk

English support forum

Moderators: sheep, Hacker, Stefan2, white

metai
Junior Member
Junior Member
Posts: 4
Joined: 2019-08-21, 13:16 UTC

Strange file-sorting-by-name quirk

Post by *metai » 2019-08-21, 13:24 UTC

Apologies if this has been already reported, a cursory search didn't yield anything for me.

Today I stumbled (visually) over a strange quirk when sorting files by name.

Given I have the files:

Code: Select all

a-a.txt
a-b.txt
a-z.txt
aa-a.txt
aa-b.txt
aa-z.txt
I expect them to be sorted in this order. After all, "-" is before "a", so "a-" should be before "aa". Right?

However, in TC (tested in latest 9.22, but I only updated before submitting this bug, so it has been in 9.1x too), the files are sorted in this peculiar way:

Code: Select all

a-a.txt
aa-a.txt
aa-b.txt
aa-z.txt
a-b.txt
a-c.txt
I tried to find a rationale for this order and the only thing I could come up with is if the dash is stripped before sorting. If that is the case ... I don't know ... it shouldn't be?

User avatar
Stefan2
Power Member
Power Member
Posts: 2676
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Strange file-sorting-by-name quirk

Post by *Stefan2 » 2019-08-21, 14:17 UTC

Hi and welcome,

just in case, do you have checked out TCs' options?


Configuration: Display > Sort method



 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

metai
Junior Member
Junior Member
Posts: 4
Joined: 2019-08-21, 13:16 UTC

Re: Strange file-sorting-by-name quirk

Post by *metai » 2019-08-22, 02:13 UTC

I did now, I actually never noticed that option. Thank you for the pointer.

The "alphabetical" sorting methods, the default "Alphabetical, considering accents" amongst them, show this odd behaviour. The "by character code" options sort in the expected way, or at least how I expect it. So this solves it for me, although I can't help but think that there is still something off with "alphabetical" sorting. For example, it sorts like this:

Code: Select all

a_a.txt
aa.txt
a-a.txt
This can't even be explained by "alphabetical" sorting ignoring everthing but alphanumeric characters.

User avatar
petermad
Power Member
Power Member
Posts: 9000
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Strange file-sorting-by-name quirk

Post by *petermad » 2019-08-23, 11:08 UTC

In general:
The option: "Strictly by numeric character code" - sorts like the NFTS file system does (as seen when choosing "Unsorted" in TC)
The option "Natural sorting: alphabetical and numbers" - sorts like Windows Explorer's Name sorting.
License #524 (1994)
Danish Total Commander Translator
TC 9.5b9 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1909) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

User avatar
MVV
Power Member
Power Member
Posts: 8412
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Strange file-sorting-by-name quirk

Post by *MVV » 2019-08-25, 09:02 UTC

I would say more, "Strictly by numeric character code" sorts like DOS file managers did. :)

And, happily, there is a registry option to disable natural sorting in Explorer so you don't have to live with it in Browse dialogs:

Code: Select all

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoStrCmpLogical"=dword:00000001

metai
Junior Member
Junior Member
Posts: 4
Joined: 2019-08-21, 13:16 UTC

Re: Strange file-sorting-by-name quirk

Post by *metai » 2019-08-25, 13:59 UTC

Alright, I do understand the difference between the sorting methods. Being a programmer, I need "by character code" since that corresponds to how programming languages would sort a directory. I was just not aware of the option to change the sorting method in the first place. My problem has been ... sorted out now (no pun intended).

What remains is my "bonus question". Why does "alphabetical" sorting ("natural" or not) sort like this:

Code: Select all

a_a.txt
aa.txt
a-a.txt
And is there a quirk or a bug there? Sorting a file without extra characters between one with an underscore and one with a dash doesn't make a whole lot of sense even in an "alphabetical" context, "natural" or not.

User avatar
petermad
Power Member
Power Member
Posts: 9000
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Strange file-sorting-by-name quirk

Post by *petermad » 2019-08-25, 17:50 UTC

2metai
And is there a quirk or a bug there?
I doubt that - since Windows Explorer sorts the same way.
License #524 (1994)
Danish Total Commander Translator
TC 9.5b9 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1909) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

metai
Junior Member
Junior Member
Posts: 4
Joined: 2019-08-21, 13:16 UTC

Re: Strange file-sorting-by-name quirk

Post by *metai » 2019-08-26, 13:29 UTC

I doubt that - since Windows Explorer sorts the same way.
Hah, fair enough. Honestly, I have not been using Explorer in years (unless it's after a fresh Windows install, to search for install TC), so I wouldn't know or care how it sorts. And you are of course perfectly correct, it is sorting the same (weird) way.

I'll call this case closed. Thank you everyone, your help (and, may I say, your unusually positive forum) is much appreciated.

User avatar
Hacker
Moderator
Moderator
Posts: 11404
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Strange file-sorting-by-name quirk

Post by *Hacker » 2019-08-26, 16:30 UTC

Message from moderator Hacker

Moved to the English forum.
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.

mushipork
Junior Member
Junior Member
Posts: 4
Joined: 2019-09-11, 07:47 UTC

Re: Strange file-sorting-by-name quirk

Post by *mushipork » 2019-09-15, 08:49 UTC

MVV wrote:
2019-08-25, 09:02 UTC
I would say more, "Strictly by numeric character code" sorts like DOS file managers did. :)
I'm using "Strictly by numeric character code", but it's not giving me the desired result.
Currently, ECc is placed before ECX, when I want to actually sort them by their character codes (all lowercase characters come after uppercase, no?)
e.g. ECC -> ECX -> ECc

User avatar
Usher
Power Member
Power Member
Posts: 644
Joined: 2011-03-11, 10:11 UTC

Re: Strange file-sorting-by-name quirk

Post by *Usher » 2019-09-15, 14:15 UTC

Windows always ignore letter case, at least on native file systems.
Regards from Poland
Andrzej P. Wozniak

mushipork
Junior Member
Junior Member
Posts: 4
Joined: 2019-09-11, 07:47 UTC

Re: Strange file-sorting-by-name quirk

Post by *mushipork » 2019-09-18, 02:33 UTC

Then is there any way I can sort them? The files are named in ascending order according to the scheme of (0-9 digits, A-Z upper case characters, a-z lower case characters, hyphens, underscores) which is the Twitter image filename order, if anyone was wondering. However, I'm finding a hard time finding a way to rename them such that it preserves the correct order.

User avatar
MVV
Power Member
Power Member
Posts: 8412
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Strange file-sorting-by-name quirk

Post by *MVV » 2019-09-18, 06:58 UTC

If you're always rename such files using the same scheme, perhaps it will be easier to use a script that will get list of selected files from TC and rename them after proper sorting.

mushipork
Junior Member
Junior Member
Posts: 4
Joined: 2019-09-11, 07:47 UTC

Re: Strange file-sorting-by-name quirk

Post by *mushipork » 2019-09-23, 08:29 UTC

MVV wrote:
2019-09-18, 06:58 UTC
If you're always rename such files using the same scheme, perhaps it will be easier to use a script that will get list of selected files from TC and rename them after proper sorting.
I'm not renaming them using that scheme. The files come named in that scheme, and they easily number in the thousands.
I just want to rename them such that a Windows or similar system orders them in the same way.

User avatar
Stefan2
Power Member
Power Member
Posts: 2676
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Strange file-sorting-by-name quirk

Post by *Stefan2 » 2019-09-23, 08:51 UTC

mushipork wrote:
2019-09-15, 08:49 UTC
...

I'm using "Strictly by numeric character code", but it's not giving me the desired result.
Currently, ECc is placed before ECX, when I want to actually sort them by their character codes
(all lowercase characters come after uppercase, no?)
e.g. ECC -> ECX -> ECc
Have you been "metai" before?



"Strictly by numeric character code" means ASCii- char code?
A = ASCII dec 65
a = ASCII dec 97
non-english chars have even bigger numbers


Google for ascii code or table
> https://www.torsten-horn.de/techdocs/ascii.htm


 
 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

Post Reply