<div class="data">
<div>01</div>
<div>04</div>
<div>03</div>
<div>02</div>
</div>
<div class="result"></div>
function func1() {
const result = document.querySelector(".result");
const divs = Array.from(document.querySelectorAll(".data > div"));
divs.sort((a, b) => +b.textContent - +a.textContent);
while(divs.length) {
result.appendChild(divs.pop());
}
}
func1();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.