I have ran across some peculiar behavior shown in the fiddle here
I'm sorting a collection in which the property by which I'm sorting is identical for all members in the collection using this function:
var doSort = function(array,key){
var data = array.sort(function(a,b){
var x = a[key],
y = b[key];
if(typeof x === 'string'){
x = x.toLowerCase();
}
if(typeof y === 'string'){
y = y.toLowerCase();
}
return ((x > y) ? -1 : ((x < y) ? 1 : 0));
});
return (direction === 'asc') ? data : data.reverse();
};
In IE and Firefox the results for the logs are 15, 16, 17. While in Chrome they are 15,2,17. It appears that after the n/2(th) element. Technically, the sort is working correctly because the collection is correctly sorted. I'm trying to gain some insight into the differences between Chrome and IE/Firefox.