var obj = {
'51' : { 'name':'name1'},
'66' : { 'name':'name2'},
'58' : { 'name':'name3'}
};
$(function() {
s = '';
$.each(obj, function(k, v) {
s += ' '+k;
});
alert(s);
});
In IE and Firefox it is 51 66 58, but in Opera and Chrome it is 51 58 66 Why is Jquery.each () sorted by key in opera, chrome? What can I do to keep my own order?
ps, if the keys of the array are a string, the result 51j 66j 58j is possible, opera and chrome try to convert the keys to an integer where possible
var obj = {
"51j" : { "name":"name1"},
"66j" : { "name":"name2"},
"58j" : { "name":"name3"}
};
source
share