17

What is the managed equivalent of StrCmpLogicalW?


Nieve string sorting rules would sort a list as:

  • Window 1
  • Window 10
  • Window 12
  • Window 2
  • Window 27
  • Window 3
  • Window 4
  • Window 5

Starting with Windows XP, Microsoft introduced StrCmpLogicalW - to sort strings in a way people expect:

  • Window 1
  • Window 2
  • Window 3
  • Window 4
  • Window 5
  • Window 10
  • Window 12
  • Window 27

Nitpicker's Corner: Some people find this sort order confusing. They're not part of this conversation.

Starting with Windows 7, Microsoft brought the functionality of StrCmpLogicalW into CompareString with the new SORT_DIGITSASNUMBERS flag:

Windows 7: Treat digits as numbers during sorting, for example, sort "2" before "10".

Without resorting to P/Invoke (obviously), what the the .NET framework equivalent of sorting strings naturally?

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219

0 Answers0