Help:Sorting

From Celeste Wiki
Jump to navigation Jump to 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[edit source]

When lists are sorted alphabetically by MediaWiki, the order of characters is sorted with Intl.Collator. This sorts accented characters correctly based on PageContentLanguage.

Android Webviews don't support this, so fallback to the old sort routine is required. The order is the same as the order of Unicode code points. Some of the more common characters are ordered as follows (in ascending order):

 !"#$%&'()*+,-./0123456789:;<=>?@ABC
DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg
hijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬
­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐ
ÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóô
õö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘ
ęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļ
ĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠ
šŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƏƒǺǻǼ
ǽǾǿȘșȚțəˆˇˉ˘˙˚˛˜˝΄΅Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘ
ΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμν
ξοπρςστυφχψωϊϋόύώЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВ
ГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеж
зийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњ
ћќѝўџҐґḂḃḊḋḞḟṀṁṖṗṠṡṪṫẀẁẂẃẄẅỲỳ–—―‗‘’‚
‛“”„†‡•…‰′″‹›‼‾⁄ⁿ₣₤₧€℅ℓ№™Ω℮⅛⅜⅝⅞←↑→↓↔
↕↨∂∆∏∑−∕∙√∞∟∩∫≈≠≡≤≥⌂⌐⌠⌡─│┌┐└┘├┤┬┴┼═║
╒╓╔╕╖╗╘╙╚╛╜╝╞╟╠╡╢╣╤╥╦╧╨╩╪╫╬▀▄█▌▐░▒▓■
□▪▫▬▲►▼◄◊○●◘◙◦☺☻☼♀♂♠♣♥♦♪♫fifl�

Categories[edit source]

Categories are sorted differently from other lists. The exact order 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 possible.

Sorting rows of a table[edit source]

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:

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

Which produces the following output:

Fruit Price
Apples £0.95
Oranges £0.85
Pears £1.15
Purple mangosteen £1.05

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[edit source]

Depending on the wiki, data-sort-value can be used to specify a sort key.

Example:

{| class="wikitable sortable"
! Name and Surname
! Height
|-
|data-sort-value="Smith , John George-Jackson"| John George-Jackson Smith
| 1.85
|-
|data-sort-value="Ray , Ian"| Ian Ray
| 1.89
|-
|data-sort-value="Bianchi , Zachary"| Zachary Bianchi
| 1.72
|-
|data-sort-value="Bianchi Maria , Adele"| Adele Bianchi Maria
| 1.82
|- class="sortbottom"
! Average:
| 1.82
|}

gives:

Name and Surname Height
John George-Jackson Smith 1.85
Ian Ray 1.89
Zachary Bianchi 1.72
Adele Bianchi Maria 1.82
Average: 1.82

Sorting in categories[edit source]

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

See also[edit source]

[[Category:Help{{#translation:}}]]