{"id":36603,"date":"2005-01-25T07:00:00","date_gmt":"2005-01-25T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2005\/01\/25\/why-do-files-and-directories-with-no-timedate-mess-up-sorting-in-explorer\/"},"modified":"2005-01-25T07:00:00","modified_gmt":"2005-01-25T07:00:00","slug":"why-do-files-and-directories-with-no-timedate-mess-up-sorting-in-explorer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20050125-00\/?p=36603","title":{"rendered":"Why do files and directories with no time\/date mess up sorting in Explorer?"},"content":{"rendered":"<p>If you have a file or directory that does not have a last-modified date, you may find that it causes Explorer to sort very strangely. (How do you get a file or directory with no last-modifiied date? It&#8217;s hard to do; you need the help of an external file system.) Why is this?\n <a href=\"http:\/\/weblogs.asp.net\/oldnewthing\/archive\/2003\/10\/23\/55408.aspx\"> As we learned earlier, a sort comparison function must impose a total order in order to produce consistent results<\/a>. The problem is that Explorer&#8217;s comparison function mis-handles files and directories with no last-modified date.\n To get some more of the background behind this, you need to know about so-called &#8220;simple pidls&#8221;. A <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/shellcc\/platform\/shell\/programmersguide\/shell_adv\/pidl_ovw.asp\"> simple pidl<\/a> is an item ID list that refers to a file or directory that does not actually exist.\n The problem is that a valid file or directory with no last-modified date looks just like one of these simple pidls becauses Explorer uses the last-modified date to distinguish whether it is manipulating a real pidl or a simple one.\n The problems with sorting occur when it comes time to decide where in the list these &#8220;real pidls that are mistaken for simple pidls&#8221; go into the sorted list. Explorer tries to keep all folders together, but if it sees a &#8220;simple pidl&#8221; it can&#8217;t tell whether that item is a folder or a file (after all, something that doesn&#8217;t exist is <strong>neither<\/strong> a file <strong>nor<\/strong> a folder) and it ends up producing inconsistent comparison results.<\/p>\n<p> Moral of the story: Be careful with your sort functions. If you produce inconsistent results in your sort function, you will get inconsistent results in your &#8220;sorted&#8221; output. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a file or directory that does not have a last-modified date, you may find that it causes Explorer to sort very strangely. (How do you get a file or directory with no last-modifiied date? It&#8217;s hard to do; you need the help of an external file system.) Why is this? As we [&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":[104],"class_list":["post-36603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>If you have a file or directory that does not have a last-modified date, you may find that it causes Explorer to sort very strangely. (How do you get a file or directory with no last-modifiied date? It&#8217;s hard to do; you need the help of an external file system.) Why is this? As we [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/36603","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=36603"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/36603\/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=36603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=36603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=36603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}