public void Sort(
IComparer<T> comparer
)
Public Sub Sort (
comparer As IComparer(Of T)
)
public:
void Sort(
IComparer<T>^ comparer
)
member Sort :
comparer : IComparer<'T> -> unit
If comparer is , then if T is an enum, this method uses the EnumComparer<TEnum>.Comparer; otherwise, the default comparer Comparer<T>.Default checks whether type T implements the IComparableT generic interface and uses that implementation, if available. If not, Comparer<T>.Default checks whether type T implements the IComparable interface. If type T does not implement either interface, Comparer<T>.Default throws an InvalidOperationException.
This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
On average, this method is an O(n log n) operation, where n is Count; in the worst case it is an O(n ^ 2) operation.
ArgumentException | The implementation of comparer caused an error during the sort. |
InvalidOperationException | comparer is , and the default comparer Default cannot find implementation of the IComparableT generic interface or the IComparable interface for type T. |