I have array containing random numbers. When I trying to sort this array via .sort() method, the result is different if array contains duplicate numbers. The code below works differently in Chrome and Firefox:
[1,2,3,4,5,6,7,8,9,2,15,3,4,5,1,2,3,4,0,2,3].sort(function(a, b) {
console.log("a=", a, "b=", b)
})
Plunker: http://plnkr.co/edit/Ocm1ZSXgkoCM7FQeH0v5
Does it bug ? How to fix this behavior to have same result in Chrome and FF ?
sortfunction is wrong. Since it returnsundefinedfor every single comparison, it's expected that sorting won't work.