title: Reorder list through span custom value javascript
body: <pre><code>&lt;ul id="CoreWebsiteTopHeader_6_list"&gt;&lt;li&gt;&lt;a class="navigation" href="/seller"&gt;&lt;span class="editableLinks" data-id="32638" data-sort="110"&gt;Seller&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="navigation" href="/about"&gt;&lt;span class="editableLinks" data-id="32639" data-sort="10"&gt;About&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="navigation" href="/faqs"&gt;&lt;span class="editableLinks" data-id="32641" data-sort="40"&gt;FAQs&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="navigation" href="/privatelending"&gt;&lt;span class="editableLinks" data-id="32646" data-sort="60"&gt;Private Lending&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="navigation" href="/problemproperty"&gt;&lt;span class="editableLinks" data-id="32647" data-sort="70"&gt;Problem Property&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li class="current"&gt;&lt;a class="navigation" href="/quickoffer"&gt;&lt;span class="editableLinks" data-id="32648" data-sort="90"&gt;Quick Offer&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class="navigation" href="/woahslowdown"&gt;&lt;span class="editableLinks" data-id="32650" data-sort="120"&gt;Stop Foreclosure&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
  </code></pre>
  
  <p>This here is my unordered list that is created programatically. I am looking to use javascript to reorder this list by the data-sort value inside of each span tag. Any help is appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>Here is my attempt using javascript pretty sure i am just missing something</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
  
  $(document).ready(function () {
      $('li').sort(sortEm).prependTo($('ul#list'));
      // Handler for .ready() called.
  });
  function sortEm(a, b) {
      return parseInt($('span', a).getAttribute('data-sort')) &lt; parseInt($('span', b).getAttribute('data-sort')) ? 1 : -1;
  }
  </code></pre>
  
  <p></p>