Help:Sorting

In many situations, lists of page titles or user names are sorted alphabetically by MediaWiki. It is also possible to use JavaScript to sort lists of data that are included in page text.

Sort order
When lists are sorted alphabetically by MediaWiki, the order of characters is the same as the order of Unicode code points. That is, the usable character that comes first in the Unicode sequence (the space character) will be ranked highest in sorted lists; when an entry in the list begins with a space, that entry is likely to be at the top of the sorted list (unless another entry in the list begins with more than one consecutive space, of course).

Some more common characters are ordered as follows (in ascending order):

!"#$%&'*+,-./0123456789:;<=>?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_' abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«­®¯°±²³´µ•¸¹º»¼½¾¿ ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ ĀāĂăĄąĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıĲĳĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňŉŊŋ ŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ ǺǻǼǽǾǿ΄΅Ά·ΈΉΊΌΎΏΐ ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰ αβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ

Categories
Categories are sorted differently from other lists. How exactly they are sorted depends on the configuration of the wiki, via $wgCategoryCollation. The default since MediaWiki 1.17 is the Unicode code point order as above, but with all the lowercase letters turned into uppercase letters. More complex orderings are also possible.

Sorting rows of a table
When a list of entries is included in a table on a page, you can use JavaScript to make the table 'sortable' (it is not possible to force a table to be sorted by a default order on page load). To do this, add the "sortable" class to the table declaration and make sure you defined headers using exclamations marks:

Which produces the following output:

By clicking on the buttons in the cell headers, the entries can be sorted by the value in that column, in either ascending or descending order.

Specifying a sort key
Depending on the wiki,  can be used to specify a sort key. In MediaWiki versions prior to 1.22.0, $wgHtml5 needs to be enabled; beginning with version 1.22.0, this is no longer needed.

Example:

gives:

Sorting in categories
Pages in categories are sorted by their title. This can be overridden by a sort key, see Help:Categories.