title: How to sort div's by content date in <span>
body: <p>I'm trying to sort <code>div</code>'s by content date on a span when the page load... What I've got is sorting. But not by date.</p>
  
  <p>Here is my code snippet:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function sortDescending(a, b) {
    var date1 = $(a).find("span").text();
    date1 = date1.split('/');
    date1 = new Date(date1[2], date1[1] - 1, date1[0]);
    var date2 = $(b).find("span").text();
    date2 = date2.split('/');
    date2 = new Date(date2[2], date2[1] - 1, date2[0]);
  
    return date1 &lt; date2 ? 1 : -1;
  };
  $(document).ready(function() {
    $('#container .element').sort(sortDescending).appendTo('#container');
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id="container"&gt;
  
    &lt;div class="element"&gt;
      &lt;p class="title"&gt;TEST 03&lt;/p&gt;
      &lt;span&gt;01/2010&lt;/span&gt;
    &lt;/div&gt;
  
    &lt;div class="element"&gt;
      &lt;p class="title"&gt;TEST 01&lt;/p&gt;
      &lt;span&gt;01/2012&lt;/span&gt;
    &lt;/div&gt;
  
    &lt;div class="element"&gt;
      &lt;p class="title"&gt;TEST 04&lt;/p&gt;
      &lt;span&gt;01/2009&lt;/span&gt;
    &lt;/div&gt;
  
    &lt;div class="element"&gt;
      &lt;p class="title"&gt;TEST 02&lt;/p&gt;
      &lt;span&gt;01/2011&lt;/span&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I know I need a function to figure out the content is a date. Just don't know how...</p>