Skip to content

M_CodeJam_Collections_ArrayExtensions_Sort__1_1

Andrew Koryavchenko edited this page Jun 17, 2018 · 7 revisions

ArrayExtensions.Sort(T) Method (T[], IComparer(T))

Sorts the elements in an Array using the specified IComparer(T) generic interface.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static void Sort<T>(
	this T[] array,
	IComparer<T> comparer
)

VB

<ExtensionAttribute>
Public Shared Sub Sort(Of T) ( 
	array As T(),
	comparer As IComparer(Of T)
)

F#

[<ExtensionAttribute>]
static member Sort : 
        array : 'T[] * 
        comparer : IComparer<'T> -> unit 

Parameters

 

array
Type: T[]
The one-dimensional, zero-base Array to sort
comparer
Type: System.Collections.Generic.IComparer(T)
The IComparer(T) generic interface implementation to use when comparing elements, or null to use the IComparable(T) generic interface implementation of each element.

Type Parameters

 

T
The type of the elements of the array.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

 

Exception Condition
ArgumentNullException array is null.
InvalidOperationException comparer is null, and one or more elements in array do not implement the IComparable(T) generic interface.
ArgumentException The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself.

See Also

Reference

ArrayExtensions Class
Sort Overload
CodeJam.Collections Namespace

Clone this wiki locally