// sort list: var list = document.getElementsByClassName('lang'); var testList = document.getElementById('test-list'); var arrList = [];
for(let i = 0; i < list.length; i++) { arrList[i] = list[i]; } arrList.sort(function (x,y) { if(x.innerText[0] > y.innerText[0]) { testList.insertBefore(y,x); return 1; } });
Sign in to make a reply
蓝色PAV
// sort list: var list = document.getElementsByClassName('lang'); var testList = document.getElementById('test-list'); var arrList = [];
for(let i = 0; i < list.length; i++) { arrList[i] = list[i]; } arrList.sort(function (x,y) { if(x.innerText[0] > y.innerText[0]) { testList.insertBefore(y,x); return 1; } });