Reputation: 16793
If you check out this JS fiddle: http://jsfiddle.net/DE5Bp and try to sort the Tariff column which I want to sort by the first digit e.g the minutes.
How can I solve this issue?
You can see I have tried to trick the plugin with the <span class="hide">
although this hasn't solved the issue.
UPDATE: http://jsfiddle.net/6jAyF/ this version forces the sorter:"integer"
Upvotes: 1
Views: 2731
Reputation: 11385
I believe you want to use addParser with type: numeric to get it to work. Here's a code snippet from http://tablesorter.com/docs/example-parsers.html that uses a numeric sorter.
// add parser through the tablesorter addParser method
$.tablesorter.addParser({
// set a unique id
id: 'grades',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// format your data for normalization
return s.toLowerCase().replace(/good/,2).replace(/medium/,1).replace(/bad/,0);
},
// set type, either numeric or text
type: 'numeric'
});
$(function() {
$("table").tablesorter({
headers: {
6: {
sorter:'grades'
}
}
});
});
Upvotes: 1