Windows Explorer Sorts Files In Unusual Way
Windows XP and above apply a new sorting algorithm when displaying files in Windows Explorer, which is that any filenames starting with numbers are sorted numerically rather than alphabetically.
For example, Explorer will sort the files 1111.txt, 112.txt, 222.txt, 33.txt as:
… because 33 < 112 < 222 < 1,111.
However, alphabetically, the correct sorting is:
because “1” < “2” < “3”.
This sorting only affects Windows Explorer; a directory listing from a command prompt lists the files alphabetically.
To revert the sorting to the classic, alphabetical sorting:
- Open an elevated command prompt
- Type (or copy and paste):
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoStrCmpLogical /t REG_DWORD /d 1 /f
- Log out and log back in.
- Requires Windows XP Service Pack 1 or better.
- Requires elevated permissions despite being set in the “current user” hive due to permissions on the Policies subkey.
- Setting can be applied to all users by using the HKLM (local machine) hive rather than HKCU (current user).
- Setting can also be set via Group Policy (gpedit.msc) under User Configuration, Administrative Templates, Windows Components, Windows Explorer by setting Turn off numerical sorting in Windows Explorer to Enabled.