let list = document.querySelector('#test-list') Array.from(list.children) .map((e, i) => ({ index: i, value: e.innerText, })) .sort((x, y) => +(x.value > y.value) || +(x.value === y.value) - 1) .map(e => list.children[e.index]) .forEach(e => { list.appendChild(e) })
Sign in to make a reply
张宇单推人