I\'ve got some json data in a map object which is sorted by time. The key is an integer id and the value is an object which contains a timestamp. However when I try to ite
Objects are un-ordered sets. You can't specify an order on them in a cross-browser complaint manner. There is no concept of original order unless it's already ordered by a rule.
So sort the data on the server and then enumerate over it in the same sorted order.
Alternatively format the JSON to be
{ "values": [
{ "someKey": "someVal" },
{ "someOtherKey": "someOtherVal" }
] }
You can iterate over the array with a for (i = 0; i < len; i++) loop and "garantuee" the original order.