jQuery tablesorter 2.0 - Using a Custom Sort Script

# tablesorter

## Using a Custom Sort Script

### Flexible client-side table sorting

Back to documentation

NOTE!

- Modified the `textSorter` option to allow setting the sorter per column v2.12:
  - *NOTE* The `textSorter` function parameters have changed! It is now `function(a, b, direction, column, table)` (previously `function(a, b, table, column)`).
  - The "Icelandic Alphabet" column is using the Sugar library v2.0+ to sort:
    - *NOTE* There are significant changes in the API of Sugar v2.0+.
    - Solved (4/28/2014)! please note that at the time of this writing, there is an issue with it not sorting properly (ref)
    - You can tell it is working properly when you sort the Icelandic Alphabet column and the numeric column numbers are sequential (see row #37).
  - The "Plain Text Sort" column is using a basic alphabetical sort (with localeCompare if set). Sort that column, then the last column to see how it differs from an alphanumeric sort.
  - The sorting of empty cells still occurs regardless of the custom `textSorter` setting.
- One custom sort used here is from the original tablesorter plugin v2.0.3. Sort the first "Plain Text Sort" column to see how it sorts alphanumeric data.
- This option is not part of the original plugin (v2.2).

# Demo

Numeric | Icelandic Alphabet | Plain Text Sort | Alphanumeric Sort
--- | --- | --- | ---
01 | A | a1a10 | a1a10
02 | Á | a1a1 | a1a1
03 | B | a2b2 | a2b2
04 | C | a1a3 | a1a3
05 | D | a2b10 | a2b10
06 | Ð | a1a20 | a1a20
07 | E | a1b04 | a1b04
08 | É | a1a0 | a1a0
09 | Ę | a1a4 | a1a4
10 | F | a1a6 | a1a6
11 | G | a1b5 | a1b5
12 | H | a1b99 | a1b99
13 | I | a2b5 | a2b5
14 | Í | b10 | b10
15 | J | b3 | b3
16 | K | b5 | b5
17 | L | b7 | b7
18 | M | b9 | b9
19 | N | b12 | b12
20 | O | b30 | b30
21 | Ó | b45 | b45
22 | P | b78 | b78
23 | Q | b67 | b67
24 | R | b62 | b62
25 | S | b01 | b01
26 | T | b0 | b0
27 | U | b77 | b77
28 | Ú | b96 | b96
29 | V | a1b55 | a1b55
30 | W | a1b84 | a1b84
31 | X | b25 | b25
32 | Y | b41 | b41
33 | Ý | b79 | b79
34 | Z | b49 | b49
35 | Þ | b94 | b94
36 | Æ | b118 | b118
37 | Ö | b80 | b80

# Javascript

# HTML

Next up: Sorting Accented Characters ››