Click or drag to resize
ArraySortT Method (T, IComparerT)
Sorts the elements in an Array using the specified IComparerT generic interface.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static void Sort<T>(
	T[] array,
	IComparer<T> comparer
)

Parameters

array
Type: T
The one-dimensional, zero-base Array to sort
comparer
Type: System.Collections.GenericIComparerT
The IComparerT generic interface implementation to use when comparing elements, or null to use the IComparableT generic interface implementation of each element.

Type Parameters

T
The type of the elements of the array.
Exceptions
ExceptionCondition
ArgumentNullExceptionarray is null.
InvalidOperationExceptioncomparer is null, and one or more elements in array do not implement the IComparableT generic interface.
ArgumentExceptionThe implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself.
See Also