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