/** * */ /** * */ /* function for sorting cards based on no. of hotspots */ window.onload=sortList; function sortList() { var list, i, switching, b, shouldSwitch; list = document.getElementById("id01"); 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; b = list.getElementsByClassName("hotspotNumber"); // Loop through all list items: for (i = 0; i < (b.length - 1); i++) { // Start by saying there should be no switching: shouldSwitch = false; /* Check if the next item should switch place with the current item: */ if (Number(b[i].innerHTML) > Number(b[i + 1].innerHTML)) { /*if next item is numerically lower than current item, mark as a switch and break the loop:*/ shouldSwitch = true; break; } } if (shouldSwitch) { /* If a switch has been marked, make the switch and mark the switch as done: */ b[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.insertBefore(b[i + 1], b[i]); switching = true; } } }