{"id":14833,"date":"2010-02-24T07:00:00","date_gmt":"2010-02-24T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/02\/24\/why-does-the-cbs_sort-combo-box-style-sort-the-left-square-bracket-so-strangely\/"},"modified":"2010-02-24T07:00:00","modified_gmt":"2010-02-24T07:00:00","slug":"why-does-the-cbs_sort-combo-box-style-sort-the-left-square-bracket-so-strangely","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100224-00\/?p=14833","title":{"rendered":"Why does the CBS_SORT combo box style sort the left square bracket so strangely?"},"content":{"rendered":"<p>Some time ago, <a href=\"http:\/\/blogs.msdn.com\/michkap\/\">Michael Kaplan<\/a> asked (and answered), <a href=\"http:\/\/blogs.msdn.com\/michkap\/archive\/2008\/10\/29\/9022296.aspx\"> How the @#%&amp;*! does <code>CBS_SORT<\/code> choose to sort it all out?<\/a> One detail in his answer is that the sorting algorithm used by <code>CBS_SORT<\/code> is basically <code>CompareString<\/code>, with special treatment for the left square bracket U+005B.\n Why is the left square bracket so special?\n It goes back to the <code>LB_DIR<\/code> message (which is in turn used by <code>DlgDirList<\/code>, <code>CB_DIR<\/code>, <code>DlgDirListComboBox<\/code>, and related functions). If you ask for drives to be added to the list or combo box, they are added in the form <code>[-X-]<\/code>, where <code>X<\/code> is the drive letter. The left square bracket is special-cased so that the drive letters sort to the top of the list.<\/p>\n<p> Of course, <code>LB_DIR<\/code> and related functions and messages are pretty old-school nowadays, but the code for them is still around, so the sort function still needs to worry about them. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago, Michael Kaplan asked (and answered), How the @#%&amp;*! does CBS_SORT choose to sort it all out? One detail in his answer is that the sorting algorithm used by CBS_SORT is basically CompareString, with special treatment for the left square bracket U+005B. Why is the left square bracket so special? It goes back [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[2],"class_list":["post-14833","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>Some time ago, Michael Kaplan asked (and answered), How the @#%&amp;*! does CBS_SORT choose to sort it all out? One detail in his answer is that the sorting algorithm used by CBS_SORT is basically CompareString, with special treatment for the left square bracket U+005B. Why is the left square bracket so special? It goes back [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/14833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=14833"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/14833\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=14833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=14833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=14833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}