$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · easy · #133

What is the output?

console.log([3, 1, 2].sort());
  1. [ 1, 2, 3 ]
  2. [ 3, 1, 2 ]
  3. [ 1, 3, 2 ]
  4. [ 2, 1, 3 ]
Default sort compares strings, which happens to match numeric order for single digits.
Play Problem Solving ▸