Help:Sorting

From WikiDOC
Jump to: navigation, search

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 descending order):

!"#$%&'()*+,-./0123456789:;<=>?@
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_'
abcdefghijklmnopqrstuvwxyz{|}~
¡¢£¤¥¦§¨©ª«­®¯°±²³´µ•¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßà áâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
Ä€ÄÄ‚ÄƒÄ„Ä…Ä†Ä‡ÄˆÄ‰ÄŠÄ‹ÄŒÄÄŽÄÄÄ‘Ä’Ä“Ä”Ä•Ä–Ä—Ä˜Ä™ÄšÄ›ÄœÄÄžÄŸÄ Ä¡Ä¢Ä£Ä¤Ä¥Ä¦Ä§Ä¨Ä©ÄªÄ«Ä¬Ä­Ä®Ä¯Ä°Ä±Ä²Ä³Ä´ÄµÄ¶Ä·Ä¸Ä¹ÄºÄ»Ä¼Ä½Ä¾Ä¿Å€ÅÅ‚ÅƒÅ„Å…Å†Å‡ÅˆÅ‰ÅŠÅ‹
ŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ
ǺǻǼǽǾǿ΄΅Ά·ΈΉΊΌΎΏΐ
ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰ
αβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ

Sorting in pages

When a list of entries is included in a table on a page, you can use JavaScript to make the table 'sortable'. To do this, just add the "sortable" class to the table declaration:

 {| class="wikitable sortable"
 |-
 ! Fruit   !! Price
 |-
 | Apples  || £0.95
 |-
 | Oranges || £0.85
 |-
 | Pears   || £1.15
 |}

Which produces the following output:

Fruit Price
Apples £0.95
Oranges £0.85
Pears £1.15

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.

Sorting in categories

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

See also