How to sort an array of objects which hold again an array of objects and I want to sort it by their last timestamp.
var weather = [{
city: 'New York',
status: 1,
response: [{
name: 'Example', lastTimestamp: '2017-12-19T12:43:14.000Z',
name: 'Example2', lastTimestamp: '2017-12-19T12:42:14.000Z'
}]
},
{
city: 'Chicago',
status: 1,
response: [{
name: 'Example', lastTimestamp: '2018-05-10T09:00:00.000Z',
name: 'Example2', lastTimestamp: '2018-05-10T09:04:00.000Z'
}]
}
]
In return I want the sorted object like this
var weather = [
{
city: 'Chicago',
status: 1,
response: [{
name: 'Example', lastTimestamp: '2018-05-10T09:00:00.000Z',
name: 'Example2', lastTimestamp: '2018-05-10T09:04:00.000Z'
}]
},
{
city: 'New York',
status: 1,
response: [{
name: 'Example', lastTimestamp: '2017-12-19T12:43:14.000Z',
name: 'Example2', lastTimestamp: '2017-12-19T12:42:14.000Z'
}]
}
]