I noticed IE9 sort order is changing elements order when comparison function returns 0.
See:
var myarray=[
{id:1,val:0},
{id:2,val:0},
{id:3,val:7},
{id:4,val:41}
];
myarray.sort(function(a,b){return a.val - b.val});
for(var i in myarray)
{
console.log(myarray[i].id);
}
Current stable versions of Chrome, Firefox, Opera and Safari got the following output: 1 2 3 4.
Same output for IE7 and IE8.
IE9 output is: 2 1 3 4
Why? Is that normal?
0.sortand not thefor-in? Afor-indoesn't guarantee any particular order, so it shouldn't be used against an Array.for-inare the same for an Array as for a plain Object. That is to say, there are no rules. It is completely implementation dependent.