title: Javascript/JQuery to sort alphabetically a list with anchors
body: <p>I have this list:</p>
  
  <pre><code>&lt;ul id="demoOne" class="demo"&gt;
      &lt;li&gt;&lt;a href='http://site/Service.aspx?shId=1154'&gt;Dhenie fotokopje aktesh nga dosja 12&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href='http://site/Service.aspx?shId=1155'&gt;Depozitim kerkesash Ankimore/Rekurse
          kunder vendimeve civile/penale 12&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href='http://site/Service.aspx?shId=1156'&gt;Dhenie Vendimesh12&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href='http://site/Service.aspx?shId=1157'&gt;Integrimi i Ish te Perndjekurve Polikite
          12&lt;/a&gt; &lt;/li&gt;
      &lt;li&gt;&lt;a href='http://site/Service.aspx?shId=1158'&gt;Dhenie Drejtesie&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href='http://site/Service.aspx?shId=1159'&gt;Gjykata e Rrethit Gjyqësor Lezhë ushtron
          juridiksionin gjyqësor civil dhe penal në territorin e qarkut Lezhë të Republikës
          së Shqipërisë.&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I want to alphabetically sort this list, using the anchor text, not the li text.
  How to do that?</p>
  
  <p>I'm using this script to sort them by li text</p>
  
  <pre><code>function sortUnorderedList(ul, sortDescending) {
          var items = $('.demo li').get();
          items.sort(function(a,b){ 
  
  
            var keyA = $(a).text();
            var keyB = $(b).text();
  
            if (keyA &lt; keyB) return -1;
            if (keyA &gt; keyB) return 1;
            return 0; 
  
            var keyA = $(a).text();
            var keyB = $(b).text();
  
            if (keyA &lt; keyB) return -1;
            if (keyA &gt; keyB) return 1;
            return 0;
  
          });
          var ul = $('.demo');
          $.each(items, function(i, li){
            ul.append(li);
          });
      }
  </code></pre>