List<T>.Sort Method (IComparer<T>) |
Sorts the elements in the entire
List< T> using the specified comparer.
Namespace: System.Collections.GenericAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntaxpublic void Sort(
IComparer<T> comparer
)
Parameters
- comparer
- Type: System.Collections.Generic.IComparer<T>
The IComparer< T> implementation to use when comparing elements, or null to use the default comparer Default.
ExceptionsException | Condition |
---|
InvalidOperationException | comparer is null, and the default comparer Default cannot find implementation of the IComparable< T> generic interface or the IComparable interface for type T. |
ArgumentException | The implementation of comparer caused an error during the sort. For example, comparer might not return 0 when comparing an item with itself. |
See Also