Click or drag to resize
ArraySortT Method (T, Int32, Int32, IComparerT)
Sorts the elements in a range of 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,
	int index,
	int length,
	IComparer<T> comparer
)

Parameters

array
Type: T
The one-dimensional, zero-based Array to sort.
index
Type: SystemInt32
The starting index of the range to sort.
length
Type: SystemInt32
The number of elements in the range 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.
ArgumentOutOfRangeExceptionindex is less than the lower bound of array.-or-length is less than zero.
ArgumentExceptionindex and length do not specify a valid range in array. -or-The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself.
InvalidOperationExceptioncomparer is null, and one or more elements in array do not implement the IComparableT generic interface.
See Also