Template:Sort/doc

This template is for optionally sorting tables by specified sortkeys.

Usage
If necessary, one can apply sorting using a sortkey that, due to CSS, is not displayed: ... . Javascript sorting is based on the text inside and outside the tags, without the tags themselves. A hidden sortkey can be put at the start.

This template makes that more convenient. The first parameter is the sortkey; the optional second parameter is the wikitext of what is to be displayed. By default, the wikitext is the sortkey.

Numerical sorting problems
Text breaks numerical sorting whether the text is before or after the number.

A dash, of any kind, in a blank cell breaks numerical sorting of a column. A dash is only allowed in front of a number. A dash after a number breaks numerical sorting of a column. Therefore a range (30-40) breaks numerical sorting of a column.

A plus sign (+) in front of a number does not break numerical sorting of a column. A plus sign in an otherwise empty cell can break numerical sorting of a column if the first non-empty cell going down a column consists of just a plus sign. A plus sign after a number can break numerical sorting if the first non-empty cell going down a column consists of a number followed by a plus sign.

References after numbers currently break numerical sorting of a column.

Leading zeroes are not necessary for numerical sorting of a column. If it seems that way, then that means the column is being sorted alphabetically.

Example usage

 * The Brothers Karamazov

It presently works through hidden CSS, as described above. A table using this template should use it in all rows.

Notes:

You should always have the same number of columns for a given table; e.g., if the wikitable will be sorting the numbers 56 (foo), 94 (bar), and 103 (baz), then your templates within that wikitable should be:

foo bar baz

If you simply code as the second parameter an indicator that two items are equally ranked, e.g., "4=", the template interpreter treats this as an additional parameter (i.e., parameter 4, which it then does not use). You must explicitly code this as parameter 2: