Array.sortInPlaceWith<'T> — Funkcja (F#)

Sortuje elementy tablicy przez mutacja tablicy w miejscu, przy użyciu funkcji danego porównania jako zamówienia.

Ścieżka obszaru nazw/modułu: Microsoft.FSharp.Collections.Array

Zestaw: FSharp.Core (w FSharp.Core.dll)

// Signature:
Array.sortInPlaceWith : ('T -> 'T -> int) -> 'T [] -> unit

// Usage:
Array.sortInPlaceWith comparer array

Parametry

  • comparer
    Type: 'T -> 'T ->int

    Funkcja do porównywania par elementów tablicy.

  • array
    Type: 'T[]

    Tablicy wejściowy.

Uwagi

Ta funkcja o nazwie SortInPlaceWith w skompilowane zestawy.Jeśli dostęp do funkcji języka, niż F# lub przez odbicie, należy użyć tej nazwy.

Przykład

Poniższy przykład kodu pokazuje, jak używać 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"

Dane wyjściowe

  

Platformy

Windows 8, Windows 7, Windows Server 2012 Windows Server 2008 R2

Informacje o wersji

F# Core wersji biblioteki

Obsługiwane: 2.0, 4.0, przenośne

Zobacz też

Informacje

Collections.Array — Moduł (F#)

Microsoft.FSharp.Collections — Przestrzeń nazw (F#)