Need a solution for array sorting in chrome browser

@pandamicro
im doing a game in html5 . In that game i need to do so many array sorting ,and the array consist of sprites and i used this function to sort my array.

x is an attribute of sprite

array.sort((function(a, b,x) { return a.x- b.x}));
&
array.sort((function(a, b,x) {if (a.x == b.x) {return 0;} else { return a.x < b.x ? -1 : 1;}}));

Both are working well when i run it in mozilla & IE after i took build , but the sorting is not working properly in the Google chrome .
Why is like that and is there any way to fix it in chrome ? like anyother way to sort my array in a proper way ???
Please help

1 Like

Can you try to add a try catch and post here the result ?

try {
...
} catch( err ) {
    console.log(err.message);
}

My 2 cents but it seems that one item in your array is incorrect