Arranging items of a List
<p>I have an Unordered List with me</p>

<pre><code>&lt;ul class="uol"&gt;
      &lt;li&gt;beta&lt;/li&gt;
      &lt;li&gt;gamma&lt;/li&gt;
      &lt;li&gt;alpha&lt;/li&gt;
&lt;/ul&gt;​​​​​
</code></pre>

<p>One of my co-workers (on a long leave) wrote some code that sorts this list. </p>

<pre><code>$(".uol li").sort(asc).appendTo('.uol');

function asc(a, b){
  return ($(b).text()) &lt; ($(a).text());    
}


function desc(a, b){
  return ($(b).text()) &gt; ($(a).text());    
}​
</code></pre>

<p>(<a href="http://jsfiddle.net/rbpQU/" rel="nofollow">fiddle</a>)</p>

<p>I am unable to understand what does the code do, especially this line:</p>

<pre><code>$(".uol li").sort(asc).appendTo('.uol');
</code></pre>

<p>Can anyone please explain this? Also, is this the best way to sort the UOL or is there a better way you know of?</p>
