title: JavaScript to sort DOM elements by some comparator, without jQuery
body: <p>Imagine some DOM elements:</p>
  
  <pre><code>&lt;ul id="list"&gt;
    &lt;li data-index="3"&gt;Baz&lt;/li&gt;
    &lt;li data-index="1"&gt;Foo&lt;/li&gt;
    &lt;li data-index="2"&gt;Bar&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>How can these elements be sorted using JavaScript and without jQuery?</p>
  
  <p>Something similar to:</p>
  
  <pre><code>document.getElementById('list').sort(function(li) { return li.dataset.index; });
  </code></pre>