Can anybody explain how in this case sort works?
var arrayNumb = [2, 8, 15, 16, 23, 42];
arrayNumb.sort();
console.log(arrayNumb); // [ 15, 16, 2, 23, 42, 8 ]
Can anybody explain how in this case sort works?
var arrayNumb = [2, 8, 15, 16, 23, 42];
arrayNumb.sort();
console.log(arrayNumb); // [ 15, 16, 2, 23, 42, 8 ]
compareFunction Optional
Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element.