I found that using sorting without comparing a function would lead to a wrong answer, and I don't know the reason.
var a = [823564440,115438165,784484492,74243042,114807987,137522503,441282327,16531729,823378840,143542612]
a.sort()
a.sort((a,b) => a-b)
Both should give me the same result, but they do not. And, of course, the latter is true.
a.sort()
[114807987, 115438165, 137522503, 143542612, 16531729, 441282327, 74243042, 784484492, 823378840, 823564440]
a.sort((a, b) => a-b)
[16531729, 74243042, 114807987, 115438165, 137522503, 143542612, 441282327, 784484492, 823378840, 823564440]
Can someone tell me the reason for this?