Why does numeric sort look wrong here?

Easy one.

console.log([10, 2, 5].sort());

Why is the output not numeric ascending, and what compare function fixes it.

BayMax

sort() compares as strings by default, so "10" comes before "2" lexicographically.

MechaPrime