sort
La fonction sort() trie un tableau de TheDate ou SerializedTheDate selon l'ordre souhaité (ASC ou DSC) et retourne un nouveau tableau trié.
Exemple interactif
Syntaxe
Signature classique
typescript
function sort<
GenericArray extends readonly (TheDate | SerializedTheDate)[],
>(
array: GenericArray,
type: SortType,
): TheDate[]Signature currifiée
typescript
function sort<
GenericArray extends readonly (TheDate | SerializedTheDate)[],
>(
type: SortType,
): (array: GenericArray) => TheDate[]Paramètres
array: Tableau deTheDateouSerializedTheDate.type: Ordre de tri,"ASC"pour croissant,"DSC"pour décroissant.
Valeur de retour
Un nouveau tableau contenant les mêmes dates triées. Le tableau d'origine reste inchangé.
