Sort an unordered list alphabetically
<p>I want to sort an unordered list alphabetically. I've tried many different javascript solutions, not one of them worked (tested in Safari and Chrome). This is the code I would like to use:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var activeLanguage = "de"

function sortUL(selector) {
  var $ul = $(selector);
  $ul.find('li').sort(function(a, b) {
    var upA = $(a).text().toUpperCase();
    var upB = $(b).text().toUpperCase();
    return (upA &lt; upB) ? -1 : (upA &gt; upB) ? 1 : 0;
  }).appendTo(selector);
};

$(document).ready(function() {
  sortUL("#WoodList");
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
&lt;ul id="WoodList"&gt;
  &lt;li&gt;Banana&lt;/li&gt;
  &lt;li&gt;Catv&lt;/li&gt;
  &lt;li&gt;Apple&lt;/li&gt;
  &lt;li&gt;Orange&lt;/li&gt;
  &lt;li&gt;Car&lt;/li&gt;
  &lt;li&gt;Pear&lt;/li&gt;
  &lt;li&gt;Banana&lt;/li&gt;
  &lt;li&gt;Cat2&lt;/li&gt;
  &lt;li&gt;Apple4&lt;/li&gt;
  &lt;li&gt;Banana1&lt;/li&gt;
  &lt;li&gt;Cat&lt;/li&gt;
  &lt;li&gt;Apples&lt;/li&gt;
  &lt;li&gt;Banana&lt;/li&gt;
  &lt;li&gt;Cat&lt;/li&gt;
&lt;/ul&gt;</code></pre>
</div>
</div>
</p>

<p>The list remains unsorted in the browser. Why is it not working ?</p>