@princedev/calculate
Version:
Fast, lightweight, and extinsible mathematical and statistical functions.
12 lines (11 loc) • 343 B
text/typescript
/**
* @name immutableSort
*
* @description - Accepts an array and returns a new array that is sorted. (numbers only)
*
* @param {Array<number>} required array to be sorted.
* @param {Array<number>} argument new sorted array.
*/
export default function immutableSort(arr: number[]): number[] {
return [...arr].sort((a, b) => a - b);
}