Closed chrishas35 closed 13 years ago
I don't have time to setup the project right now, but I think this should do the trick. Replace: $(document).ready(function() { $("#home-packages").tablesorter(); } );
with the following:
// add parser through the tablesorter addParser method
$.tablesorter.addParser({
// set a unique id
id: 'usageCount',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
// match number in span.usage-count
return s.match(/<span class="usage-count">(\d+)/)[1];
},
// set type, either numeric or text
type: 'numeric'
});
$(document).ready(function() {
$("#home-packages").tablesorter({
headers: {
0: {
sorter:'usageCount'
}
}
});
});
Appears to be doing a string sort, rather than actual integer value.
http://www.djangopackages.com/categories/apps/ shows order as 9, 7, 5, 4, 43, 40, 3...