Sorting Javascript Array with Chrome?
arrays, google-chrome, javascript, sorting
Solution
The comparer function should return a negative number, positive number, or zero (which is a convention across programming languages).
myArray.sort(function(a, b) {
return a-b;
});
Full description is here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description
Problem
Is there a way to sort an array using Chrome? Using the sort function does not work as seen in this example: ``` var myArray = [1,4,5,3,2]; myArray.sort ( function( a , b ){ return b>a }); for ( var i = 0; i < myArray.length; i++ ) { document.write( myArray[i] ) } ``` Firefox / IE / Opera / Safri output: `54321` Chrome output: `53241` jsBin example Thanks for your time!