Template:Hiddenkey

From Wikipedia, the free encyclopedia

This template is designed to simplify the process of writing sorted tables.

Tables are sorted based on the initial contents of each cell. This is ideal in many circumstances, but in some cases you might want a column to be sorted on a different key. For example, in this table:

Date Day Present
5 January 2007 12 twelve drummers drumming
4 January 2007 11 eleven pipers piping
3 January 2007 10 ten lords a-leaping
2 January 2007 9 nine ladies dancing
1 January 2007 8 eight maids a-milking
31 December 2006 7 seven swans a-swimming
30 December 2006 6 six geese a-laying
29 December 2006 5 five gold rings
28 December 2006 4 four calling birds
27 December 2006 3 three french hens
26 December 2006 2 two turtle doves
25 December 2006 1 a partridge in a pear tree

we want the last column to be sorted on the name of the present, not how many were given.

We can achieve this by putting some "invisible" text at the beginning of the cell. This template makes that text invisible for you.

{| class="wikitable sortable"
!Date!!Day!!Present
|-
|{{hiddenkey|20070105}}[[5 January]] [[2007]]
|12||{{hiddenkey|drummers}}twelve [[drummers]] drumming
|-
|{{hiddenkey|20070104}}[[4 January]] [[2007]]
|11||{{hiddenkey|pipers}}eleven [[pipers]] piping
|-

...

|-
|{{hiddenkey|20061225}}[[25 December]] [[2006]]
|1||{{hiddenkey|partridge]]}}a [[partridge]] in a pear tree
|-
|}

Notice that the {{hiddenkey}} template is also used to put the date in a format which is easily sorted.

See User:TimR/Tables for further information.