Hi Juan,
Win 7, 1123:
Calling array.sort() with no function argument on a short array modifies the array, but the result is not "sorted".
Is this a problem? I thought previous versions defaulted to a low to high sort?
Using an explicit compare function gives good results.
Mike
array:
0.533087,-1.02232,-0.855217
array.sort():
-0.855217,-1.02232,0.533087
array.sort(sortCompare):
-1.02232,-0.855217,0.533087
var array = [0.533087, -1.02232, -0.855217];
console.writeln("\narray:");
console.writeln(array);
var array = [0.533087, -1.02232, -0.855217];
array.sort();
console.writeln("\narray.sort():"); // ? bug
console.writeln(array);
function sortCompare(a, b) {
return a < b ? -1 : a > b ? 1 : 0;
}
var array = [0.533087, -1.02232, -0.855217];
array.sort(sortCompare);
console.writeln("\narray.sort(sortCompare):");
console.writeln(array);