diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 9f851441..b3a13955 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -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, diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index dcddf060..32711f73 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -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);