[Bug] Wrong 'underscore' sorting
[Bug] Wrong 'underscore' sorting
When an underscore is used as first character of a filename, it is incorrectly sorted after files that start with a numeric character. It is correctly sorted before alpha characters. See attached image.
Total Commander (Windows 95 - Windows 7) (retired for Mac)
Nimble Commander (retired Crax, Commander One, DCommander)
Macbook 12" 2016 - macOS High Sierra
Nimble Commander (retired Crax, Commander One, DCommander)
Macbook 12" 2016 - macOS High Sierra
Re: [Bug] Wrong 'underscore' sorting
Well, if something behaves not as Finder - that doesn't immediately mean a wrong behavior.
The Underscore symbol has a code point 95:
https://en.wikipedia.org/wiki/ASCII#Character_set
Numerics have, on the other hand, the range of [48,57].
PS remembered about this topic: http://magnumbytes.com/forum/viewtopic.php?f=5&t=64
The Underscore symbol has a code point 95:
https://en.wikipedia.org/wiki/ASCII#Character_set
Numerics have, on the other hand, the range of [48,57].
PS remembered about this topic: http://magnumbytes.com/forum/viewtopic.php?f=5&t=64
Re: [Bug] Wrong 'underscore' sorting
Oops, it seems I coughed up just half (surface part) of the story. Sorry about that! Here we go.
Bottom line, I wanted to suggest that this unwritten rule would be introduced in NC. I myself manipulate a lot of files and using underscores for files that I need to process later on is common practices for me (and I believe I'm not the only one).
You are right about the codes. What I meant to say was that, it seems it is an unwritten agreement (Finder, TC, many other file managers) that underscores are used to place files at the beginning (end) of ordered lists.mike wrote: ↑Mon Apr 17, 2017 6:55 amWell, if something behaves not as Finder - that doesn't immediately mean a wrong behavior.
The Underscore symbol has a code point 95:
https://en.wikipedia.org/wiki/ASCII#Character_set
Numerics have, on the other hand, the range of [48,57].
Bottom line, I wanted to suggest that this unwritten rule would be introduced in NC. I myself manipulate a lot of files and using underscores for files that I need to process later on is common practices for me (and I believe I'm not the only one).
Total Commander (Windows 95 - Windows 7) (retired for Mac)
Nimble Commander (retired Crax, Commander One, DCommander)
Macbook 12" 2016 - macOS High Sierra
Nimble Commander (retired Crax, Commander One, DCommander)
Macbook 12" 2016 - macOS High Sierra
Re: [Bug] Wrong 'underscore' sorting
I'd also expect underscores to sort on top. This is something I got used to on DOS/Windows and I always thought it's a general convention for sorting files (haven't checked on Linux though). Anyway, here's how it behaves on Windows:
Explorer:
Total Commander:
Windows CMD shell (command: dir /ON)
Explorer:
Total Commander:
Windows CMD shell (command: dir /ON)
Re: [Bug] Wrong 'underscore' sorting
As far as I can see, NC does not sort based on ASCII value, as e.g. ls in the shell does, unless you enable "case-sensitive comparison", right? If you disable case-sensitive, NC output seems to be unsorted, as with ls -f.
Re: [Bug] Wrong 'underscore' sorting
Hello, Mike! Any "owner" opinion on this? This is (right after the legacy copy/move queueing) my biggest issue with NC. Thanks in advance for letting us know. (I know you will aim for a proper / configurable / maintainable solution - no hardcoded hack. And that takes time...)
Total Commander (Windows 95 - Windows 7) (retired for Mac)
Nimble Commander (retired Crax, Commander One, DCommander)
Macbook 12" 2016 - macOS High Sierra
Nimble Commander (retired Crax, Commander One, DCommander)
Macbook 12" 2016 - macOS High Sierra
Re: [Bug] Wrong 'underscore' sorting
Hi, swoop!
Well, the situation is quite simple - I don't know the right solution to the problem.
NC uses a string comparison routine provided by CoreFoundation framework to perform sorting. Two available comparison options (case sensitivity and numeric treatment) are mapped directly to flags of this routine. I don't know any options to "tune" this lexicographical order to include exceptions for various symbols like "_".
Foundation framework, on the other hand, has a black-box comparison routine to perform an undefined "Finder-like" sorting, which apparently treats underscores accordingly, but there's no way to tune it regarding case sensitivity and numeric treatment.
A solution might be a custom comparison routine built directly atop of ICU, but it's quite serious R&D task.
Of course I'm not speaking about some hacky ways like
since it will destroy the sorting performance.
Well, the situation is quite simple - I don't know the right solution to the problem.
NC uses a string comparison routine provided by CoreFoundation framework to perform sorting. Two available comparison options (case sensitivity and numeric treatment) are mapped directly to flags of this routine. I don't know any options to "tune" this lexicographical order to include exceptions for various symbols like "_".
Foundation framework, on the other hand, has a black-box comparison routine to perform an undefined "Finder-like" sorting, which apparently treats underscores accordingly, but there's no way to tune it regarding case sensitivity and numeric treatment.
A solution might be a custom comparison routine built directly atop of ICU, but it's quite serious R&D task.
Of course I'm not speaking about some hacky ways like
Code: Select all
if( c1 == '_' )
return c2 != '_';