When I was trying to understand how the sort(i mean native js) function works (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and used their function:
let numbers = [4, 2, 5, 1, 3];
numbers.sort((a, b) => a - b);
console.log(numbers);
I added a console.log, but the first element was the second:
let numbers = [4, 2, 5, 1, 3];
numbers.sort((a, b) => console.log('a - is - '+ a));
console.log(numbers);
Why? Thanks in advance!