May 18th, 2004

String sorting is not done by ASCII code any more.

Just because you have the ASCII table memorized doesn’t mean you know how sorting works.

I remember a bug filed where somebody said that the “sort” command was sorting underscores incorrectly:

AAA__
AAAAA

this was claimed to be wrong “because underscore character follow uppercase letters and precedes lowercase letters”.

Well perhaps it does if you think ASCII sorting is the way sorting should be.

ASCII sorting is so last century.

The CompareString function describes two types of sorting, “word sort” and “string sort”. And both of them sort punctuation before letters.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.