title: Order divs by date content
body: <p>I have the following function I am using to sort my array of divs by date -</p>
  
  <pre><code>function sortDates(arrayContent) {
      arrayContent.sort(function (a, b) {
  
          var arrDate = $(a).find("#postedDate").text().replace(" posted at: ", "");
          var brrDate = $(b).find("#postedDate").text().replace(" posted at: ", "");
  
          var aTime = arrDate.split(' ')[1];
          var aDate = arrDate.split(' ')[0];
          a = new Date(aDate.split('/')[2], aDate.split('/')[1] - 1, aDate.split('/')[0], aTime.split(':')[0], aTime.split(':')[1]);
  
          var bTime = brrDate.split(' ')[1];
          var bDate = brrDate.split(' ')[0];
          b = new Date(bDate.split('/')[2], bDate.split('/')[1] - 1, bDate.split('/')[0], bTime.split(':')[0], bTime.split(':')[1]);
  
          return a &gt; b ? -1 : a &lt; b ? 1 : 0;
      });
  }
  </code></pre>
  
  <p>Where <code>arrayContent</code> =</p>
  
  <pre><code>arrayContent[0] = "&lt;div class="mHr" id="mFID"&gt; 
     &lt;div id="postedDate"&gt; posted at: &lt;b&gt;11/12/2015 11:12:16&lt;/b&gt; &lt;/div&gt;
  &lt;/div&gt;" // etc etc
  </code></pre>
  
  <p>This current function does work however I am looking to sort hundreds of divs and the runtime using this method is taking forever.</p>
  
  <p>Current limitations are that I cannot do a date converstion before populating <code>arrayContent</code> and each value added to <code>arrayContent</code> is always a string of HTML, hence why I have to find the <code>postedDate</code> and then split it accordingly to create a valid date variable.</p>
  
  <p>This is the best I have come up with and it works however as previously mentioned it is super slow.</p>
  
  <p>I also found <a href="https://stackoverflow.com/questions/7742090/how-to-sort-divs-by-content-date">this</a> question which is doing much the same as me however no faster solution.</p>