// how to sort array numbers in javascript without mutating original array.
const numbers = [100, 25, 1, 5];
const sorted = numbers.slice().sort((a, b) => a - b); // returns a new sorted array
console.log(numbers); // [100, 25, 1, 5]
console.log(sorted); // [1, 5, 25, 100]
numArray.sort((a, b) => a - b); // For ascending sort
numArray.sort((a, b) => b - a); // For descending sort