16 lines
465 B
JavaScript
16 lines
465 B
JavaScript
window.addEventListener('DOMContentLoad', () => {
|
|
sortDivs();
|
|
})
|
|
function sortDivs() {
|
|
const parentDiv = document.querySelector('div[style="display:flex"]');
|
|
const divs = Array.from(parentDiv.children);
|
|
|
|
divs.sort(function(a, b) {
|
|
const aNum = parseInt(a.textContent.match(/\d+/)[0]);
|
|
const bNum = parseInt(b.textContent.match(/\d+/)[0]);
|
|
|
|
return aNum - bNum;
|
|
});
|
|
|
|
divs.forEach(div => parentDiv.appendChild(div));
|
|
} |