Weird Directory sort order
Solution 1:
As mentioned in this Microsoft KB article:
The sort order that is used by Windows Vista, Windows XP, and Windows Server 2003 for files and folders whose names contain numerals differs from the sort order that is used by Windows 2000.
By default, the newer sort order considers strings in file and folder names as numeric content, not text. Numerals in folder and file names are sorted according to their numeric value.
In the registry (Start / Run / regedit
) you can add the NoStrCmpLogical DWORD value under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\Policies\Explorer
and set it to 1 to revert to the Windows 2000 non-numerical sorting style, or Enable the Turn off numerical sorting in Windows Explorer setting under
Computer Configuration / Administrative Templates / Windows Components / Windows Explorer
in the Local Group Policy Editor (via Start / Run / gpedit.msc
, see here for more):
Solution 2:
Pad with prepended 0's is the usual way to address an issue of this sort.
There is more information about Windows 7 sorting at http://answers.microsoft.com/en-us/windows/forum/windows_7-files/windows-7-file-name-sort-order/b6bb0847-4b98-4f6b-85da-fe6b65516153 including:
“The problem is that there is no universal standard for sorting, and what works well in one situation for some people might not for others. Another recent poster expected 'ASCII sort order' - fair enough for English language, but what about other languages? ASCII sorts upper case letters ahead of lower case ones, and has some symbols before numbers, some after, some between Z and a and some after z. Would that poster really expect file names containing symbols to be sorted like that? (999).txt, [001].txt, {555}.txt? Charlie.txt, able.txt, baker.txt? It's a perennial problem, even requiring MS to assign two different language codes to Castilian Spanish according to whether the alphabet uses the traditional sort order or the modern one.
Two of your examples include spaces. Where should these fit into the sort order? Should 'nothing' always sort before 'something' or vice versa? If you replace the spaces in your examples with, for example, underscore characters, you will get a different result again.
MS Excel has, for good reasons, a well-defined sort order which anyone who uses that program will recognize. It's different from many others, and looks like this in English (the numbers are the ASCII code points):
I guess that what I'm trying to say is you may have to adapt your filenames to suit the W7 sort order, rather than the other way round. I'm sure a lot of thought went into determining the order most likely to satisfy the majority of users (otherwise why would they have changed the system between Win2K and XP?). The main reason why I prefer the Win2K system is that it sorts hex numbers numerically; the XP system doesn't.
Apart from that, there are lots of situations where filenames including spaces are a nuisance, and sundry software will change those spaces to %20 or _ or something else.” (my emboldening)
and with reference to gpedit.msc
“this method does not work with Windows 7”.