diff --git a/_includes/datatable.html b/_includes/datatable.html index 271e7a3..2e48277 100644 --- a/_includes/datatable.html +++ b/_includes/datatable.html @@ -36,16 +36,28 @@ function sortTable(n) { one from current row and one from the next: */ x = rows[i].getElementsByTagName("TD")[n]; y = rows[i + 1].getElementsByTagName("TD")[n]; + xval = x.innerHTML; + yval = y.innerHTML; + if (!isNaN(parseInt(xval))) { + xval = parseInt(xval); + } else { + xval = xval.toLowerCase(); + } + if (!isNaN(parseInt(yval))) { + yval = parseInt(yval); + } else { + yval = yval.toLowerCase(); + } /* Check if the two rows should switch place, based on the direction, asc or desc: */ if (dir == "asc") { - if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { + if (xval > yval) { // If so, mark as a switch and break the loop: shouldSwitch = true; break; } } else if (dir == "desc") { - if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { + if (xval < yval) { // If so, mark as a switch and break the loop: shouldSwitch = true; break;