*** Welcome to piglix ***

Help:Sorting

Example Without key With key
Apple Increase10 1010
Banana Increase2 22
Cherry Decrease1 -11
Durian Steady 0

The actual sorting process will happen on your computer using client-side JavaScript. For this reason it is only possible to use this functionality if you have JavaScript enabled in your web browser. The sorting process is also dependent on your computer and the amount of data. Sorting a very large table on a slow computer may take quite long.

This is an example of a small sortable table.

Tables with more complex headers than before now sort correctly. For example:

Tables can have cells spanning multiple rows, using |rowspan=n. (See Help:rowspan).

The number of rows must be indicated with each use of rowspan. Before any sorting can be done, the rowspan setup must be correct. An incorrect rowspan organisation breaks sorting option, leaving incorrect data.

See examples below.

When sorted all the rows are filled. Tables without rowspan are much easier to maintain by less experienced editors, and by editors who are stopping by only once to edit the table.

Correct rowspan numbers, with sorting in working order:

Note that, after sorting, the rowspanning cells are cut into rows and their content is repeated (the year "2014" in the example).

Incorrect rowspan numbers breaking sorting, and causing mix-ups in rows and columns:

To make a table more compact in narrow screens, the sorting buttons can be put in an extra header row below the header cells containing text. The sorting button always ends up in the lowest header cell.

If a column contains a value multiple times then sorting the column preserves the order of the rows within each subset that has the same value in that column (stable sorting). Thus sorting based on a primary, secondary, tertiary, etc. key can be done by sorting the least-significant key first, etc. For example, to sort the table below on the Text column, then the Numbers column, first click on the "Numbers" column heading (the secondary sort key), then the "Text" column heading (the primary sort key).

Another way to sort a table using multiple sort keys is to hold down the shift key while clicking on the column headings for the subsequent sort keys. For example, to sort the table below on the Text column, then the Numbers column, first click on the "Text" column heading (the primary sort key), then hold down the shift key and click on the "Numbers" column heading (the secondary sort key).

Tables can be made sortable via client-side JavaScript by adding to their top line. These tables need to be properly formatted, with the right amount of cells. Additionally you need to make sure that the headers of your column are properly indicated in the . For this the ! character is used in the table syntax.


...
Wikipedia

...