Mono Class Library: System.Array Overview | Members

System.Array.Sort Method

Sorts the elements in the specified one-dimensional Array using the specified IComparer implementation. [Edit]

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.MayCorruptInstance, System.Runtime.ConstrainedExecution.Cer.MayFail)]
public static void Sort (Array array, IComparer comparer)

Parameters

array
The one-dimensional Array to sort. [Edit]
comparer
The IComparer implementation to use when comparing elements. Specify a null reference to use the IComparable implementation of each element. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionarray is null. [Edit]
RankExceptionarray has more than one dimension. [Edit]
ArgumentExceptioncomparer is a null reference, and one or more elements in array do not implement the IComparable interface. [Edit]
InvalidOperationExceptioncomparer is a null reference, and one or more elements in array that are used in a comparison do not implement the IComparable interface. [Edit]

Remarks

This version of Array.Sort(Array) is equivalent to Array.Sort(Array)(array, null, array.GetLowerBound(0), array.Length, comparer).

If comparer is a null reference, each element of array is required to implement the IComparable interface to be capable of comparisons with every other element in array. If the sort is not successfully completed, the results are unspecified.

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0