Filter: make sure textSorter is getting strings

This commit is contained in:
Mottie 2014-04-29 07:12:06 -05:00
parent 8217871650
commit 3b5161a5ba
2 changed files with 4 additions and 1 deletions

View File

@ -1243,6 +1243,8 @@
};
// Natural sort - https://github.com/overset/javascript-natural-sort (date sorting removed)
// this function will only accept strings, or you'll see "TypeError: undefined is not a function"
// I could add a = a.toString(); b = b.toString(); but it'll slow down the sort overall
ts.sortNatural = function(a, b) {
if (a === b) { return 0; }
var xN, xD, yN, yD, xF, yF, i, mx,

View File

@ -1082,7 +1082,8 @@ ts.filter = {
// sort parsed select options
cts = c.textSorter || '';
parsed.sort(function(a, b){
var x = a.p, y = b.p;
// sortNatural breaks if you don't pass it strings
var x = a.p.toString(), y = b.p.toString();
if ($.isFunction(cts)) {
// custom OVERALL text sorter
return cts(x, y, true, column, table);