diff --git a/sorttable/sorttable.js b/sorttable/sorttable.js index a6b65b0..d5d285b 100644 --- a/sorttable/sorttable.js +++ b/sorttable/sorttable.js @@ -167,33 +167,35 @@ sorttable = { guessType: function(table, column) { // guess the type of a column based on its first non-blank row sortfn = sorttable.sort_alpha; - for (var i=0; i 12) { - // definitely dd/mm - return sorttable.sort_ddmm; - } else if (second > 12) { - return sorttable.sort_mmdd; - } else { - // looks like a date, but we can't tell which, so assume - // that it's dd/mm (English imperialism!) and keep looking - sortfn = sorttable.sort_ddmm; - } - } - } - } + if (table.tBodies[0]){ + for (var i=0; i 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + } return sortfn; },