title: Sort array of objects with date field by date
body: <p>Give the following array of objects, I need to sort them by the date field ascending.</p>
  
  <pre><code>var myArray = [
    {
      name: "Joe Blow",
      date: "Mon Oct 31 2016 00:00:00 GMT-0700 (PDT)"
    },
    {
      name: "Sam Snead",
      date: "Sun Oct 30 2016 00:00:00 GMT-0700 (PDT)"
    },
    {
      name: "John Smith",
      date: "Sat Oct 29 2016 00:00:00 GMT-0700 (PDT)"  
    }
  ];
  </code></pre>
  
  <p>so that in this example, the final result would be John Smith, Sam Snead, and Joe Blow.</p>
  
  <p>I am trying to use lodash's <a href="https://lodash.com/docs/4.17.2#sortBy" rel="noreferrer">_.sortBy()</a>, but I can't get any sorting to take place no matter how I try to use it:</p>
  
  <pre><code>_.sortBy(myArray, function(dateObj) {
    return dateObj.date;
  });
  </code></pre>
  
  <p>or</p>
  
  <pre><code>_.sortBy(myArray, 'date');
  </code></pre>
  
  <p>What do I need to change to get my array sorted properly? I also have Moment.js, so I can use it to format the date string if needed. I tried converting the date property using .unix(), but that didn't make a difference.</p>
  
  <p>Thanks.</p>