Sortuj elementy z JS

const ul = document.querySelector('ul');
const liElements = Array.from(document.querySelectorAll('li')); //creating array from the li elements

//Sorting the li elements by text content Asc order
liElements.sort((li1,li2) => li1.textContent.localeCompare(li2.textContent));

//Append the sorted li elemtns into the ul 
appendCh(liElements,ul)

//Function that will append them all
function appendCh(liArr,parent){
  
        liArr.forEach(el => {
            parent.appendChild(el);
        })
    }
Meti