title: Sort array of JavaScript objects by property value
body: <p>I have an array of JavaScript objects. My array is defined like this:</p>
  
  <pre><code>var myObjects = [
    { id: '1', username: 'bill.jones', active: true, createdon: '03/29/2014' },
    { id: '2', username: 'woohoo', active: true, createdon: '03/28/2014' },
    { id: '3', username: 'someuser', active: true, createdon: '03/30/2014' }
  ];
  </code></pre>
  
  <p>This array is actually dynamically populated. Still, I need to sort the results by the createdon value in ascending order. To do that, I'm trying to use lodash. The createdon value represents a date. Currently, I'm trying the following:</p>
  
  <pre><code>//  ORDER BY createdOn
  myObjects.sort(function (a, b) {
    var date1 = new Date(a['createdon']);
    var date2 = new Date(b['createdon']);
    return date1 &lt; date2;
  });
  
  _.forEach(myObjects, function(result) {
    console.log(result);
  });
  </code></pre>
  
  <p>Unfortunately, myObjects is still not sorted after I run this function. What am I doing wrong?</p>
  
  <p>Thank you!</p>