I have a JS Object which contains a list of chats. What i need is to sort them in desc order according to the last_message_at value which is an epoch (Unix).
The structre of the Object is as below
var test = {
"138545616542461": {
"otherUser": {
"$id": "128636544201178",
"$priority": null,
"age": 35
},
"last_message_at": 1268482500
},
"138545616542460": {
"otherUser": {
"$id": "128636544201178",
"$priority": null,
"age": 35
},
"last_message_at": 1368482500
}
};
Typically, the sorted object should have 1368482500 at the Top. Array can be used for sorting purposes but finally the result should be an Object.
Tried some stackoverflow examples with no luck..