Namespace
The type of elements in the array.
An array of elements to sort.
The sorting order, either 'ASC' for ascending or 'DESC' for descending.
Returns a new sorted array without modifying the original array.
sortArray
const numbers = [5, 10, 2, 8];
const sortedArray = sortArray(numbers, SortOrder.ASC);
console.log(sortedArray); // Output: [2, 5, 8, 10]
const strings = ['banana', 'apple', 'orange'];
const sortedStrings = sortArray(strings, SortOrder.DESC);
console.log(sortedStrings); // Output: ['orange', 'banana', 'apple']
Generated using TypeDoc
ArrayUtils
Sort an array in ascending or descending order.