If compareFunction is not supplied, elements are sorted by converting
them to strings and comparing strings in lexicographic ("dictionary"
or "telephone book," not numerical) order. For example, "80" comes
before "9" in lexicographic order, but in a numeric sort 9 comes
before 80.
To compare numbers instead of strings, the compare function can simply subtract b from a:
function compareNumbers(a, b)
{
return a - b;
}
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort