The array presented with items listed in specific order:
{
"5":{
"Title":"Title A",
"Desc":"Description A"
},
"15":{
"Title":"Title B",
"Desc":"Description B"
},
"10":{
"Title":"Title C",
"Desc":"Description C"
},
"1":{
"Title":"Title D",
"Desc":"Description D"
},
"20":{
"Title":"Title E",
"Desc":"Description E"
}
}
The javascript code snippet below demonstrates how the order changes when executed on different browsers:
for ( var i in data ) {
alert(JSON.stringify(data[i]));
}
It has been observed that IE8 maintains the original order, while newer browsers like Chrome and IE9 rearrange the order to 1, 5, 10, 15, 20.
Do you happen to know the reason behind this behavior? Is there a method to retain the original order in modern browsers as well?
Appreciate your insights, Luke