[9,2,1,80].sort((a,b) => a>b)
// gives [ 1, 2, 9, 80 ]
[9,2,1,80].sort((a,b) => a<b)
// gives [ 80, 9, 2, 1 ]
Why? I have some code that uses the above comparison function. A comparison function for numbers should be something like (a,b) => a-b. Why the above code is correct, if it is?