jQuery tablesorter 2.0 - Sorting empty cells

# tablesorter

## Sorting empty cells

### Flexible client-side table sorting

Back to documentation

NOTE!

- Set the `emptyTo` selector below:
  - `bottom` - sort empty table cells to the bottom.
  - `top` - sort empty table cells to the top.
  - `emptyMax` - sort empty table cells as having a value greater than the max (more positive) value (added v2.16.2)
  - `emptyMin` - sort empty table cells as having a value greater than the min (more negative) value (added v2.16.2)
  - `none` or `zero`
    - Sort empty table cells as if the cell has the value equal to zero
    - None/zero has a value less than A through Z (in javascript, `0 < 'A' && 0 < 'Z'`); so in an alphabetical column, empty cells will sort at the top in an ascending sort & at the bottom in a descending sort.
    - In numerical columns, empty cells will sort as if their value was zero.
- Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
  - jQuery data `data-empty="top"`.
  - metadata `class="{ empty: 'top'}"`. This requires the metadata plugin.
  - headers option `headers : { 0 : { empty : 'top' } }`.
  - header class name `class="empty-top"`.
  - Overall `emptyTo` option.
- `emptyToBottom` option was added in v2.1.11, then replaced by the `emptyTo` option in v2.1.16.

# Demo

Set `emptyTo` option:

*Account # | First Name | Last Name | Age | Total | Discount | Diff
--- | --- | --- | --- | --- | --- | ---
A43 | Peter | Parker | 28 |  | 20.3% | +3
A255 |  | Hood |  | 19.99 | 25.1% | -7
| Clark |  | 18 | 15.89 | 44.2% | -15
A1 | Bruce | Almighty | 45 | 153.19 |  | +19
A102 | Bruce | Evans | 56 | 153.19 | 23% |
A109 | Larry | Stevens | 56 | 153.19 | 23% | 0
A99 | John | Smithy | 56 | 156 | 22% |
A119 | Mike | Rowe | 55 | -53.99 | 13% | 0

* Note The "Account #" column has the "empty-top" class name set which over-rides the `emptyTo` option (see the order of priority note above).

# Javascript

# HTML

Next up: Change the default multi-sorting key ››