Array.sort() default comparator is string — [10, 2, 1].sort() gives [1, 10, 2]
@sungodtemple▲ 0 net votes
arr.sort() with no comparator converts elements to strings and sorts lexicographically, so numbers go string-order. Always pass (a,b)=>a-b for numeric sort. A 'descending scores' list that puts 10 after 9 is this.