title: Sort by id element using jQuery
body: <p>I have this code:</p>
  
  <pre><code>&lt;li id="pi_div2"&gt;&lt;/li&gt;
  &lt;li id="pi_div5"&gt;&lt;/li&gt;
  &lt;li id="pi_div4"&gt;&lt;/li&gt;
  </code></pre>
  
  <p>I need to sort like this:</p>
  
  <pre><code>&lt;li id="pi_div2"&gt;&lt;/li&gt;
  &lt;li id="pi_div4"&gt;&lt;/li&gt;
  &lt;li id="pi_div5"&gt;&lt;/li&gt;
  </code></pre>
  
  <p>My script now:</p>
  
  <pre><code>&lt;script&gt;
      $("li[id*=pi_div]").sort(function(a,b) {
          if(a.id &lt; b.id) {
              return -1;
          }
          else {
              return 1;
          }
      }).each(function() { console.log($(this).attr("id"));});
  &lt;/script&gt;
  </code></pre>