I need to sort alphabetically a div
, I use the following strategy, I put in a div
with display: none
all li, so after inserting all in html
, I while
to while it has li
in that div
it will check which is greater, the greater, identifying it adds in another div
, which is as display:block
after I remove from div
with display:none
and stay in this loop.
My code is below:
while($('#check_presencaNone li').length > '0'){
$('#check_presencaNone li').each(function(i){
if($(this).text().toUpperCase() < valor){
valor = $(this).text().toUpperCase();
ponteiro = $(this);
}
});
ponteiro.clone().appendTo('#check_presenca');
ponteiro.remove();
console.log($('#check_presencaNone li').length);
}
When executing it is getting in an infinite loop, and I am not able to identify the error. What's wrong?