ArraySort Method (Array, Int32, Int32, IComparer) |
Sorts the elements in a range of elements in a one-dimensional
Array using the specified
IComparer.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static void Sort(
Array array,
int index,
int length,
IComparer comparer
)
Parameters
- array
- Type: SystemArray
The one-dimensional 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.CollectionsIComparer
The IComparer implementation to use when comparing elements.-or-null to use the IComparable implementation of each element.
Exceptions Exception | Condition |
---|
ArgumentNullException | array is null. |
RankException | array is multidimensional. |
ArgumentOutOfRangeException | index is less than the lower bound of array.-or-length is less than zero. |
ArgumentException | index 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. |
InvalidOperationException | comparer is null, and one or more elements in array do not implement the IComparable interface. |
See Also