Sort an array of numbers in ascending order
1 const arr = [1000, 1, 6, 2, 100, 1001, 201, 20, 305];
2 const sorted = arr.sort((a, b) => a - b);
3 console.log(sorted); // [ 1, 2, 6, 20, 100, 201, 305, 1000, 1001 ]
1 const arr = [1000, 1, 6, 2, 100, 1001, 201, 20, 305];
2 const sorted = arr.sort((a, b) => a - b);
3 console.log(sorted); // [ 1, 2, 6, 20, 100, 201, 305, 1000, 1001 ]