sort
La fonction sort() trie un tableau de chaînes en ordre croissant (ASC) ou décroissant (DSC) et retourne un nouveau tableau.
Exemple interactif
Syntaxe
Signature classique
typescript
function sort<
GenericArray extends readonly string[],
>(
array: GenericArray,
type: SortType,
): string[]Signature currifiée
typescript
function sort<
GenericArray extends readonly string[],
>(
type: SortType,
): (array: GenericArray) => string[]Paramètres
array: Tableau de chaînes à trier.type: Ordre de tri,"ASC"(croissant) ou"DSC"(décroissant).
Valeur de retour
Un nouveau tableau de chaînes triées. Le tableau d'origine reste inchangé.
