Template:Sort
Appearance
(Redirected from Template:SortKey)
<span data-sort-value="{{{1}}} !">[[{{{1}}}]]</span>
Instead of this template, consider using the data-sort-value attribute, like so: | data-sort-value="Doe, John" | John Doe . Please see WP:SORT § Specifying a sort key for a cell for details. |
This template is used on approximately 109,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
This template uses Lua: |
This template is for manually adjusting sorting order in sortable tables by specified sortkeys.
- Usage
{{Sort | 1 = {{{sort value}}} | 2 = {{{displayed value}}} }}
→ {{{displayed value}}}
The first parameter is the sortkey; the second parameter is the wikitext of what has to be displayed. By default, this is the sortkey with link brackets:
{{Sort | 1 = {{{displayed value}}} }}
→ [[{{{displayed value}}}]]
A table using this template should use it in all rows.
This template works by adding a hidden sort value, which replaces the value of the visible text for sorting purposes. The HTML output looks like: <span data-sort-value="sortvalue">[[displayed value]]</span>
.
Example
|{{Sort|Brothers Karamazov|[[The Brothers Karamazov]]}}
→ |<span data-sort-value="Brothers Karamazov !">[[The Brothers Karamazov]]</span>
- Sorting by numerical value, date, etc.
- See Help:Sortable tables#Numerical sorting problems and meta:Help:Sorting#Sort modes
- Equal rank
- If you simply code as the second parameter an indicator that two items are equally ranked, e.g. "4=", the template interpreter will treat this as an additional parameter (i.e. parameter 4, which it will then not use). You must explicitly code this as parameter 2:
{{Sort|4|2=4=}}
See also
- Template:Dsv (backlinks edit) – a shortcut for
data-sort-value="foo"
- Template:Sortname (backlinks edit) — for using names in sortable tables (using "last name, first name" as default sort key)
- Template:Date table sorting (backlinks edit) — for using dates in sortable tables
- Template:Number table sorting (backlinks edit) — for using alphabetic sort mode for numbers in sortable tables
- Help:Sortable tables
- meta:Help:Sorting