JS does something unexpected if you run sort on an array of numbers.
Array#sort() casts the array elements to strings then compares based on their UTF-16 code units. In other words, it sorts alphabetically by the first character, then the second, etc.
ALT Example code of the sort function being called on a JavaScript array containing the integers 1, 2, 3, 10, and 20. The result is an array with the numbers ordered as 1, 10, 2, 20, 30.