{"id":19,"date":"2007-03-28T18:59:00","date_gmt":"2007-03-28T23:59:00","guid":{"rendered":"synetech.ddns.net\/blogs\/smarticles\/blog\/2007\/03\/28\/computers-os-windows-explorer-file-sort\/"},"modified":"2011-06-23T23:46:55","modified_gmt":"2011-06-24T04:46:55","slug":"windows-explorer-file-sort","status":"publish","type":"post","link":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/2007\/03\/28\/windows-explorer-file-sort\/","title":{"rendered":"Windows Explorer File Sort"},"content":{"rendered":"<p>Windows Explorer allows you to sort the files and directories in a folder by various properties by clicking the appropriate column header. Folders always come before files regardless of name, and there is unfortunately no way to change this even though sometimes it is desirable to sort with mixed folders\/files.<\/p>\n<p>The algorithm for sorting by name is mostly straightforward but with some bumps. Knowing the sort order allows you to choose characters to use as the first character in a file or folder name to control sorting, for example when creating a filing system.<\/p>\n<p>For the most part, the algorithm sorts files\/folders by name according to their ASCII values, expect that case is ignored because on Windows, filenames are case-insensitive, that is <strong>&#8220;MYFILE&#8221;<\/strong>, <strong>&#8220;MyFile&#8221;<\/strong>, and <strong>&#8220;myfile&#8221;<\/strong> are all the same file\u2014<acronym title=\"if I recall\/remember correctly\">iirc<\/acronym> NTFS can do case-sensitive but it&#8217;s actually a hack (mapping).<\/p>\n<p>You should also be aware that numbers are treated as numbers and not strings.  For example <strong>&#8220;123blah&#8221;<\/strong> will come after <strong>&#8220;2blah&#8221;<\/strong> since 123 is bigger than 2, even though <strong>&#8220;1&#8221;-&#8220;2&#8221;-&#8220;3&#8221;<\/strong> comes before <strong>&#8220;2&#8221;<\/strong>.  This behavior can be changed with the NoStrCmpLogical option of the Explorer policies (set HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoStrCmpLogical to dword:00000001).<\/p>\n<p>Another bump in the algorithm is that the following characters appear out of order: <strong>+, &lt;, and &gt; <\/strong> They come after all other characters, in this order. Also, <strong>&#8216;<\/strong> and <strong>&#8211;<\/strong> are ignored altogether when they are the first character.<\/p>\n<p>Here is a list of characters in the order that they will be sorted when used as the first character:<\/p>\n<style>\ntable, td {padding:3px; white-space:nowrap; font-family:monospace; border:solid 1px #000000; border-collapse:collapse}\nsup {color:#ff8080;}\n<\/style>\n<table  class=\" table table-hover\" summary=\"File System Sort Order of Special Characters\">\n<tfoot>\n<tr>\n<td><sup>1<\/sup> &#8211; Not (normally) allowed as a filename character<\/td>\n<\/tr>\n<tr>\n<td><sup>2<\/sup> &#8211; Not in ASCII order<\/td>\n<\/tr>\n<tr>\n<td><sup>3<\/sup> &#8211; Not used in sort when first character<\/td>\n<\/tr>\n<\/tfoot>\n<tbody>\n<tr>\n<td>&nbsp; (space)<\/td>\n<\/tr>\n<tr>\n<td>!<\/td>\n<\/tr>\n<tr>\n<td>&#8221; <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>#<\/td>\n<\/tr>\n<tr>\n<td>$<\/td>\n<\/tr>\n<tr>\n<td>%<\/td>\n<\/tr>\n<tr>\n<td>&amp;<\/td>\n<\/tr>\n<tr>\n<td>(<\/td>\n<\/tr>\n<tr>\n<td>)<\/td>\n<\/tr>\n<tr>\n<td>* <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>,<\/td>\n<\/tr>\n<tr>\n<td>.<\/td>\n<\/tr>\n<tr>\n<td>\/ <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>: <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>;<\/td>\n<\/tr>\n<tr>\n<td>? <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>@<\/td>\n<\/tr>\n<tr>\n<td>[<\/td>\n<\/tr>\n<tr>\n<td>\\ <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>]<\/td>\n<\/tr>\n<tr>\n<td>^<\/td>\n<\/tr>\n<tr>\n<td>_<\/td>\n<\/tr>\n<tr>\n<td>`<\/td>\n<\/tr>\n<tr>\n<td>{<\/td>\n<\/tr>\n<tr>\n<td>| <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>}<\/td>\n<\/tr>\n<tr>\n<td>~<\/td>\n<\/tr>\n<tr>\n<td>+ <sup>2<\/sup><\/td>\n<\/tr>\n<tr>\n<td>&lt; <sup>1,2<\/sup><\/td>\n<\/tr>\n<tr>\n<td>= <sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<td>&gt; <sup>1,2<\/sup><\/td>\n<\/tr>\n<tr>\n<td>&#8211;<\/td>\n<\/tr>\n<tr>\n<td>&#8216; <sup>3<\/sup><\/td>\n<\/tr>\n<tr>\n<td>&#8211; <sup>3<\/sup><\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#808080; font-size:25%\">&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This knowledge will be used in a later article to create a filing system that will allow organization of files and folders since Windows doesn\u2019t really have symbolic links and WinFS has been cancelled until at least Windows Vienna.<\/p>\n<div class=\"tagcloud\"><a href=\"https:\/\/synetech.ddns.net\/blogs\/smarticles\/tag\/computers\/\" rel=\"tag\">Computers<\/a>, <a href=\"https:\/\/synetech.ddns.net\/blogs\/smarticles\/tag\/operating-systems\/\" rel=\"tag\">Operating Systems<\/a>, <a href=\"https:\/\/synetech.ddns.net\/blogs\/smarticles\/tag\/windows\/\" rel=\"tag\">Windows<\/a>, <a href=\"https:\/\/synetech.ddns.net\/blogs\/smarticles\/tag\/windows-explorer\/\" rel=\"tag\">Windows Explorer<\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>Windows Explorer allows you to sort the files and directories in a folder by various properties by clicking the appropriate column header. Folders always come before files regardless of name, and there is unfortunately no way to change this even though sometimes it is desirable to sort with mixed folders\/files. The algorithm for sorting by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14,9,10,36],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-computers","tag-operating-systems","tag-windows","tag-windows-explorer"],"_links":{"self":[{"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/posts\/19","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":0,"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"wp:attachment":[{"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/synetech.ddns.net\/blogs\/smarticles\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}