System.Collections.Generic.List<T>.Sort Method
Sorts the elements in the list using the default comparer.


public void Sort ()


InvalidOperationExceptionThe default comparer cannot find a IComparable<T> or IComparable implementation for type T.


This method uses the default comparer for type T to determine the order of list elements. If there is no default comparer, then the method throws InvalidOperationException. The default comparer for a given element type T is defined in the Description section of this (class List<T>) specification.

At worst, this operation is O(n2), where n is the number of elements to sort. On average it's O(n log n).


Namespace: System.Collections.Generic
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0