Reputation: 5469
I'm using Tablesorter to sort a multi-column table.
One column of my table has numbers that I would like to sort alphabetically, eg. 10, 111, 2, 4444, 55, 9
.
How do I disable the number detection in Tablesorter and let it sort all as text ?
Just setting:
headers: {
0: { sorter: "text" },
}
didn't work.
Upvotes: 1
Views: 178
Reputation: 86433
I don't know if this parser works in every case you need, but it works with the subset of data provided (demo)
$(function() {
$.tablesorter.addParser({
id: "nums",
is: function() { return false; },
format: function(s) {
var first = s.charAt(0);
return first + "-" + s.substring(1);
},
type: "text"
})
$('table').tablesorter({
headers: {
0: {
sorter: "nums"
}
}
});
});
Upvotes: 1