Array.sortInPlaceWith, <'T> Funkce (F#)
Seřadí prvky pole podle pole na místě, pomocí porovnání dané funkce jako pořadí mutace.
Cesta k oboru názvů nebo modul: Microsoft.FSharp.Collections.Array
Sestavení: FSharp.Core (v FSharp.Core.dll)
// Signature:
Array.sortInPlaceWith : ('T -> 'T -> int) -> 'T [] -> unit
// Usage:
Array.sortInPlaceWith comparer array
Parametry
Poznámky
Tato funkce se nazývá SortInPlaceWith v kompilovaný sestavení.Pokud tento název jazyka než F# nebo prostřednictvím reflexe, přístup k funkci použít.
Příklad
Následující příklad kódu ukazuje, jak použít Array.sortInPlaceWith.
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.sortInPlaceWith sortFunction array1
printfn "After sorting: "
array1 |> printfn "%A"
Výsledek
Platformy
Windows 8, Windows 7, Windows Server 2012 Windows Server 2008 R2
Informace o verzi
F# základní verze knihovny
Podporovány: 2.0, 4.0, přenosné