Click or drag to resize
ArraySort Method (Array, IComparer)
Sorts the elements in a one-dimensional Array using the specified IComparer.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static void Sort(
	Array array,
	IComparer comparer
)

Parameters

array
Type: SystemArray
The one-dimensional Array 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
ExceptionCondition
ArgumentNullExceptionarray is null.
RankExceptionarray is multidimensional.
InvalidOperationExceptioncomparer is null, and one or more elements in array do not implement the IComparable 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