Skip to content

sort ​

The sort() function sorts an array of TheDate or SerializedTheDate 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 | SerializedTheDate)[],
>(
  array: GenericArray,
  type: SortType,
): TheDate[]

Curried signature ​

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

Parameters ​

  • array: array of TheDate or SerializedTheDate values.
  • 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.