Why, when you sort by name, doesn’t it actually sort by name?

When you right-click on the desktop or in an Explorer window and select "Sort by... Name", why doesn't it actually sort by name?

Because "Sort according to the default sort order for the column whose title is... Name" is too long.

The default sort order for the first column (whose name is "Name") is to sort by name, mostly. The actual sort order for the desktop and file folders (note: implementation detail, subject to change at any time) is really a two-tiered sort. First, the items are sorted into buckets; the first bucket contains the virtual folders, the second bucket contains file folders (directories), and the third bucket contains regular files. Sorting within the first bucket is done by the "item order"; sorting within the second and third buckets is by name. (And it's not by ASCII code any more. There's also special treatment for numbers and periods.)

The "item order" (a term I just made up) for My Computer, My Documents, and Recycle Bin were specifically chosen in Windows 95 so that the icons on the desktop appeared in that order. I believe it was in Windows 2000 that the order was changed to My Documents, My Computer, Recycle Bin in order to put the focus on document management.

(And those who have read Appendix A of my book will know what sort of application compatibility problems arose from that simple change.)

Comments (25)
  1. BOFH says:

    On a computer with Windows 2000 Pro SP4 I sometimes see a strange thing occur in Explorer windows (not the desktop); The default sort is on Name, and sometimes I want to see the latest files or folders in that folder so I click on the Date column label.

    Some time after that, sometimes instantly, sometimes several seconds or minutes afterwards, the windows "repaints" and the sort order is no longer on Date.

    When I look at the column labels, I now notice that BOTH Name and Date now have the indicator showing that the content is sorted by them.

    I have to click on Date once again, which removes the indicator from Name and sorts correctly on Date again.

    I have never seen that on XP as I can recall, so I guess it got "fixed" or something…

    But it sure is annoying on that old machine.

    That box has a version of an expensive third party app that only works in Win2K, that’s why I still keep it around.

  2. Thom says:

    Sorry, I absolutely must gripe now.  I hate, Hate, HATE that Explorer sorts by "Type" rather than extension.  That has caused me much frustration over the years.

    I frequently need to group files by extension – for instance all .jpg files or all .gif files – and can’t.  Why, because so many programs group numerous file extensions under their "Type."  

    Yes, I know I can search for .ext, but that’s a pain when almost 100% of the time sorting by extension rather than type is what I need in Explorer.  IMO sorting by type is a a major Explorer team blunder.

  3. David Walker says:

    Having "My Documents" first and then "My Computer" below it just seems so wrong, wrong, wrong.  It just doesn’t FEEL right.  For one thing, the computer is a larger container than "My Documents".  I think that we system types often work with stuff that is not in "My Documents", more so than "regular" users do.

    I always move My Computer to the upper-left-hand corner of the screen, where the gods intended it to be!!  :-)

  4. David Walker says:

    BOFH:  Sometimes, old applications can be fooled by the application compatibility settings.  Make a shortcut, and then set the shortcut to tell the application that it’s running under Windows 2000.  This doesn’t always work, but if you haven’t tried it, it might work.

  5. BOFH says:

    No, there is no way around it.

    The app also has a driver component which isn’t exactly the most system compatible piece of code out there.

    There is no way of making it work reliably in WinXP, and it’s attached to specialized hardware, so it can’t be run in a VM either.

    It’s no problem, I just keep the machine around, and it has been running 24×7 for eight years now.

  6. John says:

    Thom: Just write your own column handler – it’s fun!  This would only work with Details view, but real men already use Details view.

    David: I completely agree with "My Computer" vs "My Documents".  However, I suspect most "normal" people would see it the other way.

    Is it possible to change the "item order" with a shell extension?  A quick glance at the documentation seems to indicate no.  I think it may be possible with a column handler (assuming the extension gets invoked for virtual files/folders), but I’m not sure; even if it were possible, this wouldn’t help with the desktop as it doesn’t have a Details view.  I guess one could hook the Explorer ListView control and try to reverse-engineer the internal messages/structures (in my experience not a winning proposition).

  7. Simon says:

    David, John: You should be able to change that order with the TweakUI PowerToy (Desktop -> First Icon -> My Computer).

  8. Koro says:

    That reminds me, I have a problem with the Open/Save dialogs under XP. For some reason, it sorts "My Computer" contents by free space, but only in the Open/Save dialogs! Also, my "default" explorer settings are to sort by name, I don’t know how I got it to do that, neither how to reset it to default behavior :(

  9. John says:

    As long as we’re talking about Explorer, my Explorer windows eventually "forget" my customized toolbar settings.  I set "Text options" to "Show text labels", but eventually the setting will revert back to "Selective text on right" for no apparent reason.  I just learned to live without it.  My personal favorite Explorer experience is when it just freezes for a couple seconds either when getting the contents of a local directory, though this could possibly be related to a few extensions I am using.

  10. Ryan says:

    I have always wondered if there was a way to change this sorting order.  For example, when looking at the contents of a directory in Explorer, I would prefer to have buckets two and three (directories and files) sorted by name together.  I have grown accustomed to this style of viewing directories from other OSes and would be interested to hear if there was a way to make it happen in Explorer.  I have tried looking for an extension to do this in past, but I wasn’t successful.

  11. Jonathan says:

    John: You should read Mark Rusinovich’s "The case of the…" blog entries – he shows how to debug those hangs. It has really helped me in the past to catch exactly these (winzip and anti-virus shell extensions, in my case).

  12. James says:

    Getting rid of the last Win2k system (Workstation, but in a server role: handling licenses for some expensive CAD app) was a very welcome moment for me, particularly since its HDD had started choking: with a bit of tweaking, they’re all crammed into three WinXP systems (one physical, two virtual) on an ex-server with a proper RAID array.

    My biggest irritation, besides the way the Explorer file list will spend time sorting entries even when you haven’t requested any sort order, is that Vista’s file association window goes and regenerates itself each time you update an entry – which meant that undoing a certain office suite’s hijacking of all the Office file extensions took much longer than it should have, requiring re-sorting and scrolling back down to where I had been before the previous change each time. (Beyond being hosted in an Explorer window, I don’t know how much they have in common, but they do behave similarly.)

    I’d be interested to know why the ordering itself was changed to control the icon order on the Desktop, rather than just positioning those three icon in the desired order, which seems like much less of a hack.

  13. Raymond – you forgot the #1 most confusing thing about the Desktop sort order.

    The folder view shown on the desktop is actually not the "Desktop" namespace location, nor is it any of the individual desktop folders.  It is its own special amalgam of the Personal Desktop folder, the Public Desktop folder, and some special regitems.

    The sorting of the public and personal Desktop folders happen independently, which can result in "Zune" (in the Public folder) being sorted above Outlook (in the Personal folder).

  14. Miral says:

    Something that irritates me about folder views in Vista is that when you drag & drop a file to them (copy/move) then it will "helpfully" put the file at the spot you dropped it and switches off the folder’s sorting.  (This is in Details view.)  Which means I have to go turn it on again.

    I can kind of see that it’s a "feature", and I’m positive it was an intentional change (because it doesn’t do that on XP), but it bugs me.

  15. Will says:

    Arrghh, I too must complain about Explorer in XP, but not about sorting.  I have a folder with 500 .pdf files that I am checking out one-by-one.  I scroll down, double click a pdf to open, and after explorer launches the pdf viewer it automatically resets the scroll position.  When I close that pdf file I have to scroll back down a couple hundred lines to find where I was and view the next pdf in line.  It would be irritating enough if the pdf were being changed but it’s not.  Who’s the genius who came up with this behavior?  

  16. Drak says:


    Why not use the cursor down key? I’m sure explorer remembers which file was last selected, so pressing the cursor down will go to the next file (and update scrolling).

  17. BryanK says:

    Drak — not if some code in the PDF viewer is calling:


    as that will not only reset the scroll position in every Explorer window (by design), but also deselect everything.  (You’re supposed to use this call after you’ve changed a file association, so Explorer can repaint the icons and whatnot that are on the screen.)

    Now, as for why the PDF viewer in use is dumb enough to call that, I don’t know.  But there are plenty of PDF viewers in existence that do other extremely dumb things, so it wouldn’t surprise me if this (or something like it) was happening.

  18. John says:

    Miral: I want to kill the person who is responsible for that change in behavior.  Slowly and painfully.

  19. Will says:

    Drak – It doesn’t remember.

    BryanK – Accck!  I wonder if that is what’s happening.  I just clicked on a .chm in the same folder with no such problem so it is the app (Foxit) and not Explorer.

  20. somename says:


    > I hate, Hate, HATE that Explorer sorts by "Type"

    I can’t understand your love-hate relation with this program. Please either get used to it (it is 13 years for Christ’s sake) or use another shell/file manager. I personally am using konqueror when possible.


    >Having "My Documents" first and then "My Computer" below it just seems so wrong, wrong, wrong.

    Same as above.

    Should I recommend you another desktop? Some that can at least be easily reproduced… By the way why not create a script to customize the system. Something to copy your settings to another computer. I use roaming profiles, oops works only in one network. For everything else just keep a copy of your home directory on a thumb drive and copy it in the new environment.

    I am sorry that some of the solutions do not work on Windows in all cases. It is your choice.

    By the way do you pay for this products that you hate, hate, hate so much?

    I personally get payed to use them. Just like Reymond here gets payed to produce them.

    Lighten up. The default will be always the opposite of what you want. This is the result of the usability testing done at Microsoft. Easy to use for the first time vs easy and productive.

  21. Cliff Barbier says:

    I can understand the three buckets and sorting within them first… although, I would like the ability to turn that off when necessary.

    The part of sorting that I never understand is why Auto Arrange doesn’t work in Explorer.  I don’t think it’s worked right since Win98, that I can remember.  (Haven’t used Vista)  

    The assumed functionality is that, when you tell a tiled window to arrange icons by Name, and auto-arrange, that the file and folder icons will be arranged by name (within their buckets), EVERY time you look at the window.  

    This is not the case.  I haven’t had a Windows PC since 95 that would keep icons auto-arranged.  What ends up happening is that new files and folders get added at the bottom of the window in order of creation date.  Hitting F5 to refresh doesn’t fix this.  The only way to fix it I’ve found is to right-click, and click to arrange by name again.  This is a waste of my time, since I’ve already told the computer to do this for me automatically.  

  22. David Walker says:

    Well, I don’t need TweakUI or another shell; I just drag the My Documents folder out of the way, move My Computer up to the upper-left corner of the screen, and then move My Documents below that.  I don’t tell Windows to sort the icons on the desktop or auto-arrange them.

    This works fine… except I frequently am configuring new computers for my own use, or reconfiguring an old one, so I have to do it pretty often.

    Thom:  I didn’t say that I hate Windows; that was someone else.  I think it’s great.  It has quirks and behaviors that don’t please 100% of the people 100% of the time, though, which is too bad.   :-)

  23. John says:

    Just as a follow-up to my previous comments, I discovered you can subclass the SysListView32 window Explorer uses to display the files/folders.  Watch for the LVM_SORTITEMS message and pass your own sorting method to the list view’s window proc.  In the sorting method, lParam1 and lParam2 are pointers to ITEMIDLISTs representing the files/folders to sort and lParamSort is a pointer to a IShellView2 representing the displayed folder.  If you just return 0, the result is that files and folders are sorted together in ascending alphabetical order (My Computer, Recycle Bin, etc are still sorted in their own bucket but still in alphabetical order).  Fascinating; I will have to play around with the Shell some more.

  24. Koro says:

    John: Yeah, and Raymond will curse at you hard when he has to make a change to that code a few years down the road :)

    Then people will complain that Windows is bloated with backward compatibility cruft.

    Bottom line: Don’t do that.

  25. Friday says:

    People, SortOrderIndex registry entry doesn’t work?

    (I don’t use icons on desktop so can’t try right now).

Comments are closed.

Skip to main content