Seq.sortBy<'T,'Key> Function (F#)
Collapse the table of content
Expand the table of content

Seq.sortBy<'T,'Key> Function (F#)

Applies a key-generating function to each element of a sequence and yields a sequence ordered by keys. The keys are compared using generic comparison as implemented by

Namespace/Module Path: Microsoft.FSharp.Collections.Seq

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
Seq.sortBy : ('T -> 'Key) -> seq<'T> -> seq<'T> (requires comparison)

// Usage:
Seq.sortBy projection source


Type: 'T -> 'Key

A function to transform items of the input sequence into comparable keys.


Type: seq<'T>

The input sequence.




Thrown when the input sequence is null.

The result sequence.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. Therefore, this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence. This is a stable sort, that is, the original order of equal elements is preserved.

This function is named SortBy in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

F# Runtime

Supported in: 2.0, 4.0


Supported in: 3

Community Additions

© 2015 Microsoft