Function sort

Returns a new sorted array

  • If the sortFn is ommited, the array is sorted in ascending order.
  • If the sortFn is provided, the array is sorted according to the return value of the sortFn.
  • If the source array is empty, it returns an empty array of the same type.
const source = [3, 2, 1];
sort(source) // [1, 2, 3]
sort(source)((a, b) => b - a) // [3, 2, 1]