|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
Array.sortWith<'T>, fonction (F#)
// Signature:
Array.sortWith : ('T -> 'T -> int) -> 'T [] -> 'T []
// Usage:
Array.sortWith comparer array
open System let array1 = [| "<>"; "&"; "&&"; "&&&"; "<"; ">"; "|"; "||"; "|||" |] printfn "Before sorting: " array1 |> printfn "%A" let sortFunction (string1:string) (string2:string) = if (string1.Length > string2.Length) then 1 else if (string1.Length < string2.Length) then -1 else String.Compare(string1, string2) Array.sortWith sortFunction array1 |> printfn "After sorting: \n%A"
Sortie
Avant de tri : [|" <> » ; « et » ; « && » ; « &&& » ; « < » ; « > » ; « | » ; « || » ; « |||"|] Après l'avoir trié : [|" et » ; « | » ; « < » ; « > » ; « && » ; « || » ; « <> » ; « &&& » ; « |||"|]