Sort a numeric array using Javascript

 //javascript sort() function sorts by characters rather than numbers
console.log([1, 11, 26, 2, 36, 123].sort()); // [ 1, 11, 123, 2, 27, 34 ]


 //numeric sort of the number array using arrow function (descending order)
numArray = [1, 11, 26, 2, 36, 123].sort((a, b) => a - b);

console.log(numArray); //[ 1, 2, 11, 26, 36, 123 ]


 //numeric sort of the number array using arrow function (ascending order)
numArray = [1, 11, 26, 2, 36, 123].sort((a, b) => b - a);

console.log(numArray); // [ 123, 36, 26, 11, 2, 1 ]