Help:Sorting

Sortable tables have the ability to sort table rows based on the values inside a specific column. This is done through.

Note that sortable tables use JavaScript for sorting, and does not currently work on the mobile skin.

Creating a sortable table
Making a table sortable is easy since all that is required is appending the "sortable" class. However, certain situations - such as sorting with numbers or using a table footer - may require extra input, as detailed further down the page.

This results in:

Clicking the arrows will let you sort the column alphabetically / numerically. If you want to sort by multiple columns, hold down Shift when you sort your second column.

data-sort-type
By default, columns are sorted in ASCII order. This isn't a problem in most cases, but can be quite problematic when sorting numbers, as 10, 20, 100 will be sorted as 10, 100, 20 (since it sorts it by the first "letter" first, rather than numerically). This can be fixed using the "data-sort-type" attribute on column row headers.

can contain multiple different values, but the most common ones are: Note that if each cell in the column does not have a value of the correct type, there is a chance sorting for the whole column will go back to default.
 * text
 * number - Expects a numerical value, points, commas, spaces, "+", or "-".
 * currency - Expects a number with $, £, €, or ¥ in front (ex: $100, ¥10000)
 * date

Example:

This results in:

data-sort-value
Sometimes what you want to show in a column doesn't correspond to what order you would like it sorted by. In cases such as these  is used.

Example:

This results in:

Unsortable columns
If you have a table where you want one of the columns to not be sortable, you can do this by adding the class "unsortable" to its header.

Example:

This results in:

Table footer
If you don't wish for a row at the bottom of a table to be sorted (such as a "totals" row), this can be accomplished by adding  to the row.

Example:

This results in:

Further help and feedback
es:Ayuda:Tablas ordenables fr:Aide:Tri ja:ヘルプ:ソーティング pl:Pomoc:Sortowanie ru:Справка:Таблицы/сортировка zh:Help:表格排序