<!DOCTYPE html>
<html>
<title>Sort a HTML List Numerically</title>
<body>
<p>Click the button to sort the list numerically:</p>
<button onclick="sortList()">Sort</button>
<ul id="id01">
<li>4</li>
<li>3</li>
<li>1</li>
<li>7</li>
<li>1000</li>
<li>5234234</li>
<li>2</li>
<li>100</li>
</ul>
<script>
function sortList() {
var list, i, switching, b, shouldSwitch;
list = document.getElementById("id01");
switching = true;
while (switching) {
switching = false;
b = list.getElementsByTagName("LI");
for (i = 0; i < (b.length - 1); i++) {
shouldSwitch = false;
if (Number(b[i].innerHTML) > Number(b[i + 1].innerHTML)) {
shouldSwitch = true;
break;
}
}
if (shouldSwitch) {