To sort an array without mutating the original array with JavaScript, we make a copy of the original array.
For instance, we write
const sorted = [...arr].sort();
to make a copy of arr with the spread operator.
And then we call sort to sort the copied array.