title: Sort array by dates in React JS
body: <p>I have an array of objects as follows :</p>
  
  <pre><code>let cars = [
      {"id":20,"mileage":41300,"make":"Golf", initialRegistration:"09/02/2010"}, 
      {"id":21,"mileage":51300,"make":"Passat", initialRegistration:"06/04/2012"},
      {"id":22,"mileage":61300,"make":"Audi", initialRegistration:"02/01/2018"},
      {"id":23,"mileage":20300,"make":"Touran", initialRegistration:"17/09/2013"},
      {"id":24,"mileage":10300,"make":"Polo", initialRegistration:"26/07/2014"}
  ];
  </code></pre>
  
  <p>And I want to sort it by <code>initialRegistration</code>.</p>
  
  <p>I tried to do it as follows :</p>
  
  <pre><code>let sortedCars = cars.sort((a, b) =&gt; Date.parse(a.initialRegistration) - Date.parse(b.initialRegistration));
  
  let sortedCars1 = cars.sort((a, b) =&gt; new Date(a.initialRegistration) - new Date(b.initialRegistration));
  
  let sortedCars2 = cars.sort((a, b) =&gt; new Date(a.initialRegistration).getTime() - new Date(b.initialRegistration).getTime());
  </code></pre>
  
  <p>But none of these attempts did not work. The results that I get is :</p>
  
  <pre><code>Golf - 09/02/2010
  Passat - 06/04/2012
  Audi - 02/01/2018
  Touran - 17/09/2013
  Polo - 26/07/2014
  </code></pre>
  
  <p><a href="http://jsfiddle.net/jwm6k66c/1588/" rel="noreferrer">Here is fiddle.</a> </p>