I have a column in a table that contains ICD9 codes. So it can have values like 4379
, 5186
,45933,
V420or
E9539`.
For this sorting does not work. It considers a column as a digit type and applies sort. Current output is :
4379
5186
45933
V420
E9539
I want this column to be sorted in text manner.
It's output should be
4379
45933
5186
E9539
V420
AS you can see I want order to be based on first character, then second character and so on.
How can I achieve this type of sorting.
I'm not 100% sure which version of tablesorter you're using, so I'll answer for both.
The original tablesorter (tablesorter.com) v2.0.5 isn't showing either of those outputs, but since you want to apply a basic text sort, not a numeric sort, set the headers
option to force it to sort text (demo):
$('table').tablesorter({
headers: {
0: { sorter: 'text' }
}
});
If you are using my fork of tablesorter (currently v2.23.3), then the basic alphanumeric sort does produce the output above. To switch to using a basic text sort, set the textSorter
option to use the basic text sort (demo):
$(function () {
$('table').tablesorter({
theme: 'blue',
textSorter: {
// use sortText on the first column only
0 : $.tablesorter.sortText
}
});
});