29

What is the sorting order used in Windows Explorer?

I was specifically wondering what special characters sort after the alphabets?

As far as I can tell (test), all special characters seem to be sorted before the alphabets. But I couldn't identify the order. (for. eg. '@' comes after '%' which is not that way on the keyboard)

Screenshot

Are there any special characters that would be sorted after the alphabets?

2
  • 2
    This might help, danhotchkiss.com/archives/38
    – CLockeWork
    Commented Nov 27, 2013 at 14:35
  • Archived at web.archive.org/web/20120415042232/danhotchkiss.com/archives/38. Most interesting note: - and ' are ignored while sorting, so the next character counts! Commented Nov 30, 2022 at 12:17

6 Answers 6

25

I did some testing and the overall ordering seems to be as follows...

Symbols
Latin (ordered by Unicode value (U+xxxx))
Greek (ordered by Unicode value (U+xxxx))
Cyrillic (ordered by Unicode value (U+xxxx))
Hebrew (ordered by Unicode value (U+xxxx))
Arabic (ordered by Unicode value (U+xxxx))

Numbers
Latin (ordered by Unicode value (U+xxxx))
Greek (ordered by Unicode value (U+xxxx))
Cyrillic (ordered by Unicode value (U+xxxx))
Hebrew (ordered by Unicode value (U+xxxx))
Arabic (ordered by Unicode value (U+xxxx))

Letters
Latin (ordered by Unicode value (U+xxxx))
Greek (ordered by Unicode value (U+xxxx))
Cyrillic (ordered by Unicode value (U+xxxx))
Hebrew (ordered by Unicode value (U+xxxx))
Arabic (ordered by Unicode value (U+xxxx))

enter image description here


Sorting Rule Sequence vs Observed Order

It's worth noting that there are really two ways of looking at this. Ultimately, what you have are sorting rules that are applied in a certain order, in turn, this produces an observed order. The ordering of older rules becomes nested under the ordering of newer rules. This means that the first rule applied is the last rule observed, while the last rule applied is the first or topmost rule observed.

Sorting Rule Sequence

1.) Sort on Unicode Value (U+xxxx)
2.) Sort on culture/language
3.) Sort on Type (Symbol, Number, Letter)

Observed Order

  • The highest level of grouping is by type in the following order...

    1.) Symbols
    2.) Numbers
    3.) Letters

    Therefore, any symbol from any language comes before any number from any language, while any letter from any language appears after all symbols and numbers.

  • The second level of grouping is by culture/language. The following order seems to apply for this:

    Latin
    Greek
    Cyrillic
    Hebrew
    Arabic

  • The lowest rule observed is Unicode order, so items within a type-language group are ordered by Unicode value (U+xxxx).

3
  • 4
    Your answer isn't fully complete. The default sort order for Latin letters is based on the basic letters A–Z, Þ, hence why ỹ (U+1EF9) is sorted before Z (U+005A), because ỹ is sorted as Y. Then a letter like Æ is sorted as if it was written "AE". Finally, a certain locale might reorder these letters, such as Austrian German putting Ä as a letter between A and B, and Swedish putting Ä after Z (between Å and Ö). According to the root.xml of Unicode, Cyrillic Ѓ is sorted as Ђ, and Chinese characters are base on unihan sort order.
    – Liggliluff
    Commented Apr 3, 2020 at 22:04
  • Thanks for that. But it does not fully accord with what I see (UK English). Symbol underscore appears AFTER (<< sorry, italics not found in this comment input control) Numbers.
    – ChrisJJ
    Commented Aug 4, 2021 at 13:08
  • @ChrisJJ Odd, i can not reproduce that. (In Windows 10; by switching the Format in the old Control Panel’s Region item to English (United Kingdom). But i can reproduce the different sorting of Ä with the Swedish format setting. _ always stayed sorted above 0 and 1.) Commented Sep 6 at 10:23
16

The answers provided in this discussion, while interesting, are somewhat esoteric. The simple answer is that none of the symbols are sorted after the letters (not taking into account the special way ' and - is handled, see below).

The other answers state that symbol characters are sorted by Unicode value. However, for Windows 10 File Explorer characters in the Basic Latin block (ASCII characters), this is not strictly true.

The following table of ASCII characters allowed in filenames (showing the characters, their Unicode values and a description of the character) is arranged in the sort order used by Windows 10 File Explorer.


ASCII Characters Allowed in Filenames
Listed in File Explorer's ascending sort order
           Unicode
Character  Hex Value     Description
---------  ------------  ----------------------------------------
!          0021          exclamation mark
#          0023          number sign
$          0024          dollar sign
%          0025          percent sign
&          0026          ampersand
(          0028          left parenthesis
)          0029          right parenthesis
,          002C          comma
.          002E          full stop/period
;          003B          semicolon
@          0040          commercial at sign
[          005B          left square bracket
]          005D          right square bracket
^          005E          circumflex accent
_          005F          low line, underscore
`          0060          grave accent
{          007B          left curly bracket
}          007D          right curly bracket
~          007E          tilde
+          002B          plus sign
=          003D          equal sign
0-9        0030 – 0039   digit zero through digit nine
A-z¹       0041 – 005A,  capital letter A through Z
           0061 – 007A   small letter a through z
𝘪𝘨𝘯𝘰𝘳𝘦𝘥²
'          0027          apostrophe
-          002D          hyphen/minus
¹ File Explorer's sort order does not differentiate between uppercase and lowercase letters in filenames
² File Explorer ignores ' and - when sorting unless there's a direct conflict with another filename, in which case, the opposed filename takes precedence (e.g. foo is sorted before -foo); the only exception is when they're the only character in a filename – they'll then be after ,

A careful examination of the above table will reveal that + and = are not in the order they would be in if File Explorer sorting was done strictly by Unicode Value.

If they were sorted strictly by Unicode Value:
  +  would come before  ,
  =  would come before  @

See this post for how the sorting order works for other code sets: https://superuser.com/a/971721/1080517

1
  • 1
    I revised this answer extensively based on the other answers that clarified ' and `-' behaving differently than expected, and I also made it look a little nicer.
    – Maybe
    Commented May 11, 2023 at 23:38
3

For Latin alphabet users looking for a character to collate after most everything else, you can use (as longer answers have said) characters from other alphabets (Greek, Cyrillic, Hebrew, Arabic)

I use Omega ( Ω ) or the last Hebrew letter ( ת‎ ).

2

For anybody finding this page via search engines, here's the list I tested with Windows 10.

' - ! # $ % & ( ) , ; @ [ ] ^ _ ` { } ~ + =

These are the 'special characters' I can make using a US English keyboard.

(I just made a bunch of folders with single character names inside a empty folder. I also would have liked to find this answer, as I have problems with getting things to remain where I want them.)

2
  • Great! But... why?! Commented Nov 30, 2022 at 10:51
  • Not true by the way. It's more complex: -, ' are ignored while sorting, so the next character counts! Commented Nov 30, 2022 at 12:16
-4

They are probably sorted by their corresponding value in the ASCII table.

The actual sorting algorithm is probably more complex and also takes any other Unicode character into account. But the character shown in your examples appear in the ASCII table and their values (at least the order) also maps to Unicode.

5
  • 1
    '{' still sorts before 'z'. I specifically wanted to know a character that would place it after all the alphabets. Commented Nov 27, 2013 at 14:43
  • 1
    @laggingreflex: I guess you could just use Commented Nov 27, 2013 at 15:32
  • 4
    Can you specify more than "probably". I think "probably" answers should be comments, don't you? Commented Sep 11, 2015 at 17:28
  • He will "probably" get upvoted, but there's a chance he could be downvoted into oblivion. Commented Sep 10, 2017 at 19:47
  • Simply trying it out will show that files are not sorted in ASCII order. This answer from JCB has the entire list in order. Commented Nov 20, 2020 at 20:55
-4

In my experience, I use tilde ~ or greek omega Ω to force an item to the end of a list.

1
  • 2
    Does not work. ~ is ordered before any letters.
    – Daniel
    Commented Aug 9, 2018 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .