Strange file-sorting-by-name quirk

English support forum

Moderators: white, Hacker, petermad, Stefan2

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

Strange file-sorting-by-name quirk

Post by *metai »

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: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Strange file-sorting-by-name quirk

Post by *Stefan2 »

Hi and welcome,

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


Configuration: Display > Sort method



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

Re: Strange file-sorting-by-name quirk

Post by *metai »

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: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Strange file-sorting-by-name quirk

Post by *petermad »

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 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Strange file-sorting-by-name quirk

Post by *MVV »

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 »

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: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Strange file-sorting-by-name quirk

Post by *petermad »

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 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | 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 »

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: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Strange file-sorting-by-name quirk

Post by *Hacker »

[mod="Hacker"]Moved to the English forum.[/mod]
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 »

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: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Strange file-sorting-by-name quirk

Post by *Usher »

Windows always ignore letter case, at least on native file systems.
Andrzej P. Wozniak
Polish subforum moderator
mushipork
Junior Member
Junior Member
Posts: 4
Joined: 2019-09-11, 07:47 UTC

Re: Strange file-sorting-by-name quirk

Post by *mushipork »

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: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Strange file-sorting-by-name quirk

Post by *MVV »

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 »

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: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Strange file-sorting-by-name quirk

Post by *Stefan2 »

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


 
 
Post Reply