I have an Unordered List with me
<ul class="uol">
<li>beta</li>
<li>gamma</li>
<li>alpha</li>
</ul>
One of my co-workers (on a long leave) wrote some code that sorts this list.
$(".uol li").sort(asc).appendTo('.uol');
function asc(a, b){
return ($(b).text()) < ($(a).text());
}
function desc(a, b){
return ($(b).text()) > ($(a).text());
}
(fiddle)
I am unable to understand what does the code do, especially this line:
$(".uol li").sort(asc).appendTo('.uol');
Can anyone please explain this? Also, is this the best way to sort the UOL or is there a better way you know of?