const arr = [10, 11, 9]
arr.sort() // it returns [10, 11, 9] because element be covert to string before sorting
arr.sort((a, b) => a - b)) // it returns [9, 10, 11], you MUST SPECIFY THE COMPARE FUNCTION when sorting numbers
I wasted 1 hour because Javascript sort numbers as string
const arr = [10, 11, 9]
arr.sort() // it returns [10, 11, 9] because element be covert to string before sorting
arr.sort((a, b) => a - b)) // it returns [9, 10, 11], you MUST SPECIFY THE COMPARE FUNCTION when sorting numbers