This question already has an answer here:
I have a data structure that gets returned from the server via PHP which is sorted correctly based on timestamp. When I view this data structure from the client it is sorted by the parent key. Can I disable this default behavior or better yet how would I sort based on the timestamp via jquery on the client side?
Here is what the data structure looks like being returned from the server:
[conversation] => Array
(
[7943] => Array
(
[timestamp] => 1364062233
)
[9482] => Array
(
[timestamp] => 1364125301
)
[9475] => Array
(
[timestamp] => 1364128494
)
)
Here is what I see after it's returned to the client:
$.post("test_function.php", { function: 'test' }, function(data) {
console.log(data);
}, "json");
DATA:
conversation: Object
7943: Object
timestamp: 1364062233
9475: Object
timestamp: 1364128494
9482: Object
timestamp: 1364125301
</div>