NaturalSort.Extension icon indicating copy to clipboard operation
NaturalSort.Extension copied to clipboard

Not behaving the same behavior as Windows Explorer for "X", "X-1", "X-2",...

Open maettu-this opened this issue 11 months ago • 2 comments

Hi Tom,

Glad having found your extension for completing a test case for my own open source project https://sourceforge.net/p/y-a-terminal/ I unfortunately ran into an issue or limitation:

Windows Explorer behavior

Image

NaturalSort behavior

Image

Is this something that could be refined in NaturalSort?

Note that Windows Explorer has the shown behavior also on @, ', –, _, ¦, [, ] but not on (, ), , ., !, $ nor #. Unfortunately, havent't found a Microsoft resource where the behavior is specified in full detail. However, haven't either found a specification which characters are handled by NaturalSort.

Best regards, Matthias

maettu-this avatar Feb 16 '25 10:02 maettu-this

Note the ["X", "X-1", "X-2"] (as in the title) seems to be correctly sorted.

It's different once you add the .: ["X.log", "X-1.log", "X-2.log"]. So it's about . vs -, in my opinion.

I suspect it's due to Windows sorting the non-alphanumerical characters in some special way (my machine):

Image

NaturalSort uses this for CurrentCulture:

a_a
a-a
a,a
a;a
a!a
a.a
a'a
a(a
a)a
a[a
a]a
a{a
a}a
a@a
a&a
a#a
a%a
a`a
a^a
a+a
a=a
a~a
a$a

And this for Ordinal:

a!a
a#a
a$a
a%a
a&a
a'a
a(a
a)a
a+a
a,a
a-a
a.a
a;a
a=a
a@a
a[a
a]a
a^a
a_a
a`a
a{a
a}a
a~a

So it seems to be culture specific somehow.

There is this test that used to ensure it's aligned with Windows Explorer:

https://github.com/tompazourek/NaturalSort.Extension/blob/master/tests/NaturalSort.Extension.Tests/NaturalSortComparerTests.cs#L57-L58

But maybe the situation or the sorting changed somehow since? I guess it's possible the test data was invalid.

I don't have a clear idea on how to resolve this, it needs more research.

tompazourek avatar Feb 19 '25 09:02 tompazourek

I have now isolated these problematic characters (between two x) that might behave differently to Windows Explorer:

x'x
x+x
x-x
x=x
x`x

I don't know yet how to adjust the sorting algorithm though...

tompazourek avatar Feb 20 '25 15:02 tompazourek