Skip to content

sort

The sort() function sorts an array of TheDate according to the desired order (ASC or DSC) and returns a new sorted array.

Interactive example

Syntax

Classic signature

typescript
function sort<
  GenericArray extends readonly TheDate[],
>(
  array: GenericArray,
  type: SortType,
): TheDate[]

Curried signature

typescript
function sort<
  GenericArray extends readonly TheDate[],
>(
  type: SortType,
): (array: GenericArray) => TheDate[]

Parameters

  • array: Array of dates in TheDate format.
  • type: Sort order, "ASC" for ascending, "DSC" for descending.

Return value

A new array containing the same dates sorted. The original array remains unchanged.

See also

  • max - Returns the maximum date of a tuple
  • min - Returns the minimum date of a tuple
  • between - Checks membership in an interval

Released under the MIT license.