title: How can I sort elements by numerical value of data attribute?
body: <p>I have multiple elements with the attribute: <code>data-percentage</code>, is there a way of sorting the elements into ascending order with the lowest value first using either JavaScript or jQuery?</p>
  <p>HTML:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;testWrapper&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;30&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;62&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;11&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;43&quot;&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Desired result:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;testWrapper&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;11&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;30&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;43&quot;&gt;
    &lt;div class=&quot;test&quot; data-percentage=&quot;62&quot;&gt;
  &lt;/div&gt;
  </code></pre>