Добрый день, при сортировке таблицы на возрастание/убывание, выходит так
соответственно, нужно чтобы сортировка была 1,2,3,4,5,6,7... и т.д. по порядку
<script>
document.title = "[LL_REPTAG_MYID NODEINFO:NAME /]";
function sortId(){
var pretype = $("#pretype_sort").text();
if(pretype == "" || pretype == "desc"){
$("#pretype_sort").text("asc");
}else{
$("#pretype_sort").text("desc")
}
var table, rows, switching, i, x, y, shouldSwitch;
table = document.getElementById("sorting_table");
switching = true;
/* 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.getElementsByTagName("TR");
/* Loop through all table rows (except the
first, which contains table headers): */
for (i = 1; i < (rows.length - 2); i++) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Get the two elements you want to compare,
one from current row and one from the next: */
x = rows[i].getElementsByTagName("TD")[0];
y = rows[i + 1].getElementsByTagName("TD")[0];
// Check if the two rows should switch place:
if(pretype == "" || pretype == "desc"){
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
// I so, mark as a switch and break the loop:
shouldSwitch= true;
break;
}
}else{
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
// I so, mark as a switch and break the loop:
shouldSwitch= true;
break;
}
}
}
if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark that a switch has been done: */
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
}
}
}
</script>
toLowerCase
в операторах сравнения говорит о том же. Ну или добавьте им ведущих нулей...