Skip to content

@jonamar /sort
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
trying to wrap my head around sorting
var myArray = [10, 44, 32, 100, 0, 44, 3, 4];
console.log(myArray.toString()); // 10, 44, 32, 100, 0, 44, 3, 4
myArray.sort();
console.log(myArray.toString()); // 0,10,100,3,32,4,44,44 --> sorted like strings
myArray.sort(function (a, b) {
return a - b;
console.log(a,b);
});
console.log(myArray.toString()); // 0,3,4,10,32,44,44,100 --> sorted numerically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.