SHARE
Facebook X Pinterest WhatsApp

Windows XP Changes Filename Sorting

Microsoft changed the filename sort algorithm in Windows XP, making it different from all previous versions. The only reference I’ve found is the Microsoft Knowledge Base Article Q318872 that addresses an incorrect sort order in Windows XP. This article in turn refers to a new Windows API function called StrCmpLogicalW, which implements the new sort […]

Sep 2, 2003
Channel Insider content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Microsoft changed the filename sort algorithm in Windows XP, making it different from all previous versions. The only reference I’ve found is the Microsoft Knowledge Base Article Q318872 that addresses an incorrect sort order in Windows XP. This article in turn refers to a new Windows API function called StrCmpLogicalW, which implements the new sort algorithm.

I have almost 5,000 filenames that were constructed so that Windows Explorer would sort the filenames chronologically (using the old character-by-character sort algorithm). These files have been distributed across the United States. I now have the task of renaming all these files so that Windows XP will sort them chronologically and still have them sort correctly in previous Windows versions.

There is a small Registry fix that will restore the old sort order, but I can’t rely on all my users installing this fix. I want to bring this to the attention of computer users. As users develop program tasks that require filename sorts, they need to be aware of this unpublicized Microsoft change that will directly impact their desired end results.

Fred Gould

There are actually two distinct points here. First, Windows XP has a new sorting algorithm for filenames. Second, this algorithm may break down when filenames contain ten or more consecutive digits. The problem with long strings of digits has been fixed in the latest Windows XP service pack, but the change to the sort algorithm remains.

In previous versions of Windows, filenames are sorted text-wise, character by character. File1.txt, File10.txt, and File100.txt are all placed before File2.txt, because the digit 1 comes before the digit 2. Most users have grown accustomed to zero-padding sequential numbers in filenames—File010.txt correctly comes after File002.txt. Under Windows XP, though, each block of consecutive digits is treated as a number and sorted as such. Even without zero-padding, File10.txt comes after File2.txt.

For most users, this will be a benefit, not a problem. If you’re one of the few who have developed solutions that rely on the old order, you can make the Registry tweak mentioned above. Launch REGEDIT from the Start menu’s Run dialog and navigate to HKEY_LOCAL_ MACHINESoftwareMicrosoftWindows CurrentversionPoliciesExplorer. In the right-hand pane, find or create a DWORD value named NoStrCmpLogical. Double-click it and set its data to 1 (no matter whether it’s hex or decimal). Now Win XP will sort filenames the old way.

Recommended for you...

June Roundup: M&A Moves Across the Shifting Channel Landscape
Jordan Smith
Jul 7, 2025
Leadership Roundup: New CEOs Highlight June Moves
Jordan Smith
Jul 2, 2025
Workspan AI Looks to Solve Channel Ecosystem Complexity
Victoria Durgin
Jun 25, 2025
May Roundup: Mergers and Acquisitions From Around the Channel
Jordan Smith
Jun 2, 2025
Channel Insider Logo

Channel Insider combines news and technology recommendations to keep channel partners, value-added resellers, IT solution providers, MSPs, and SaaS providers informed on the changing IT landscape. These resources provide product comparisons, in-depth analysis of vendors, and interviews with subject matter experts to provide vendors with critical information for their operations.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.