我是 Javascript 新手。在尝试了许多 Javascript 和 Jquery 插件对我的 HTML 表进行排序并最终感到失望之后,我决定实现自己的 Javascript 代码来对 HTML 表进行排序。我写的代码是 W3Schools 的更新。
function sortFunctionNumeric(n) {
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
table = document.getElementById("reportingTable");
switching = true;
//Set the sorting direction to ascending:
dir = "asc";
/*Make a loop that will continue until
no switching has been done:*/
while (switching) {
//start by saying: no switching is done:
switching = false;
rows = table.rows;
/*Loop through all table rows (except the …Run Code Online (Sandbox Code Playgroud) javascript ×1