# tablesorter

## Dealing with text strings in numerical sorts

### Flexible client-side table sorting

Back to documentation

NOTE!

- This functionality is new as of version 2.0.10 (not part of the original plugin).
- When a column is sorted numerically ( `sorter:"digit"` ) any text in that column will, by default, be given a zero value. Sort the last column (#9) to see the problem with this method.
- Overall `stringTo` option added in version 2.1.16.
- String options changed in version 2.1.16; setting the value to:
  - `"max"` will treat any text in that column as a value greater than the max (more positive) value. Renamed from "max+".
  - `"min"` will treat any text in that column as a value greater than the min (more negative) value. Renamed from "max-".
  - `"top"` will always sort the text to the top of the column.
  - `"bottom"` will always sort the text to the bottom of the column.
  - `"none"` or `"zero"` will treat the text as if it has a value of zero.
- Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
  - jQuery data `data-string="top"`.
  - metadata `class="{ string: 'top'}"`. This requires the metadata plugin.
  - headers option `headers : { 0 : { string : 'top' } }`.
  - header class name `class="string-top"`.
  - Overall `stringTo` option.
- Sort columns three through eight to see how the sort has changed. Note that the text is sorted separately from the numeric values.
- The `emptyTo` option defaults to bottom, so all empty cells will sort at the bottom of the table, except for the second column.

# Demo

Account # | Difference | 3: Ratings (max) | 4: Ratings (min) | 5: Change (max) | 6: Change (min) | 7: Change (top) | 8: Change (bottom) | 9: Change (zero)
--- | --- | --- | --- | --- | --- | --- | --- | ---
A43 | -35 | 01 | 01 | -.1 | -.1 | -.1 | -.1 | -.1
A255 | 33 | 02 | 02 | N/A #1 | N/A #1 | N/A #1 | N/A #1 | N/A #1
A33 | 2 | 03 | 03 | N/A #2 | N/A #2 | N/A #2 | N/A #2 | N/A #2
A1 | -5 | 04 | 04 | -8.4 | -8.4 | -8.4 | -8.4 | -8.4
A102 | 99 | 05 | 05 | -2.2 | -2.2 | -2.2 | -2.2 | -2.2
A10 | -1 | 06 | 06 | 97.4 | 97.4 | 97.4 | 97.4 | 97.4
A02 | 0 | 07 | 07 | 23.6 | 23.6 | 23.6 | 23.6 | 23.6
A55 | 44 |  |  | 11.4 | 11.4 | 11.4 | 11.4 | 11.4
A87 | 04 | NR | NR | 5.2 | 5.2 | 5.2 | 5.2 | 5.2
A012 |  | NR | NR |  |  |  |  |

# Javascript

# HTML

Next up: Disable or set the column parser using class names ››