Page 1 of 1

Oddity: Leading hyphen in filename ignored for sorts?

Posted: 21 Feb 2012 04:10
by j_c_hallgren
Noticed something unusual tonight: Renamed some files with a leading dash/hyphen expecting them to be sorted near top of list when in seq by filename but they are in order based on 2nd-nth chars. :?

Checked WE on this W2K sys and it does the same...a leading + or underscore acts like one would expect but not the - which I don't quite understand why.

Re: Oddity: Leading hyphen in filename ignored for sorts?

Posted: 22 Feb 2012 11:22
by admin
Wow, I never noted this! Quite shocking...

Check this (search for "hyphen"):
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
The functions CompareString, CompareStringEx, lstrcmp, lstrcmpi, LCMapString, LCMapStringEx, FindNLSString, and FindNLSStringEx all default to use of a "word sort" technique. For this type of sort, all punctuation marks and other nonalphanumeric characters, except for the hyphen and the apostrophe, come before any alphanumeric character. The hyphen and the apostrophe are treated differently from the other nonalphanumeric characters to ensure that words such as "coop" and "co-op" stay together in a sorted list.