var list = document.getElementById('test-list'), ls = list.children, i, j;
for (i=0;i<ls.length;i++) { for (j=i+1;j<ls.length;j++) { if (ls[i].innerText > ls[j].innerText) { list.insertBefore(ls[j], ls[i]) } } }
Sign in to make a reply
曦冶程
var list = document.getElementById('test-list'), ls = list.children, i, j;
for (i=0;i<ls.length;i++) { for (j=i+1;j<ls.length;j++) { if (ls[i].innerText > ls[j].innerText) { list.insertBefore(ls[j], ls[i]) } } }