I am adding this answer because I see this referenced thread when duplicate labeling and some newer and cleaner solutions are available now.
Another solution is to use a utility library such as Lodash and use its Collection#sortBy . It produces very clean code and promotes a more functional programming style, which leads to fewer errors. In one glance, it becomes clear what the intention is if the code.
The problem with the OP can simply be solved as:
var sortedObjs = _.sortBy(data, 'date');
More information? For instance. we have the following nested object:
var users = [ { 'user': {'name':'fred', 'age': 48}}, { 'user': {'name':'barney', 'age': 36 }}, { 'user': {'name':'fred'}}, { 'user': {'name':'barney', 'age': 21}} ];
Now we can use _. shorthand user.age property to specify the path to the property to be mapped. We will sort user objects by nested age. Yes, this allows you to map nested properties!
var sortedObjs = _.sortBy(users, ['user.age']);
Want everything to be the other way around? No problems. Use _. Reverse
var sortedObjs = _.reverse(_.sortBy(users, ['user.age']));
Want to combine both instead of a chain ?
var sortedObjs = _.chain(users).sortBy('user.age').reverse().value();