如何按子对象的值对对象进行排序?
例子:
[
{
name: 'Jhon',
old: 20,
last_message: {
text: 'blah',
timestamp: 1378188846
}
},
{
name: 'Bill',
old: 45,
last_message: {
text: 'Hello, Jhon!',
timestamp: 1378188956
}
},
{
name: 'Steave',
old: 34,
last_message: {
text: 'Bye! ;)'
timestamp: 1378188952
}
}
]
应该是对象的顺序独立于最大值last_message.timestamp
。
怎么做?