Could any one tell me why the result of below code is: 3,5,1,6,2,4


var myArray = [1,2,3,4,5,6];
myArray.sort( function(x, y) {
if (x % 2)
return -1;
if (x % 2 == 0)
return 1;
}
);
alert(myArray);