Template:Sortkey: Difference between revisions

Template page
w:c:strategywiki>Najzere
m (repurpose, category sort)
m (3 revisions imported: Imported from https://strategywiki.org/)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<span style="display:none;">{{#time:Ymd|{{{1}}}}}</span>{{{1}}}<noinclude>
<span style="display:none;">{{#if:{{{1|}}}|{{#time:Ymd|{{{1}}}}}|{{{2|!}}}}}</span>{{#if:{{{1|}}}|{{{1}}}}}<noinclude>
 
{{documentation}}
{{documentation}}
[[Category:Templates|{{PAGENAME}}]]</noinclude>
[[Category:Templates|{{PAGENAME}}]]</noinclude>

Latest revision as of 18:27, 28 October 2023

! This page has been transcluded from Template:Sortkey/Documentation.


This template returns a hidden string that can be used to enforce a specific sort order in sortable tables.

Usage[edit source]

First unnamed parameter

The most useful feature of the template is creating chronological sortkeys by using a date. Most date formats will be recognized, such as "January 1, 2011" or "2011-Jan-01". For instance:

{{sortkey|January 1, 2011}} will return <span style="display:none;">20110101</span>January 1, 2011.
Second unnamed parameter

You can also use this template to create your own sortkey, not based on time, by using the second unnamed parameter by itself. This can be useful for getting text to sort how you want (such as sorting "The Goonies" by the letter "G"). Note that when using the second unnamed parameter, nothing is returned after the sortkey.

{{sortkey||Goonies, The}} will return <span style="display:none;">Goonies, The</span>.
No parameters

If no parameters are used, the template returns an exclamation point, which will sort before most other characters.

{{sortkey}} will return <span style="display:none;">!</span>.

Example[edit source]

Code Result
{{sortkey|Dec-2011}} 20111201Dec-2011
{{sortkey|October 3, 2005}} 20051003October 3, 2005
{{sortkey}}The beginning of time !The beginning of time
{{sortkey|5-3-2008}} 200803055-3-2008
{{sortkey|03-Jan-2007}} 2007010303-Jan-2007
{{sortkey||20110222}}My birthday 20110222My birthday