Export (0) Print
Expand All

UserTrackPointCollection.Sort Method

Sorts the elements in the List<T> or a portion of it.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Sort() Sorts the elements in the entire List<T> using the default comparer. (Inherited from List<T>.)
Public method Sort(Comparison<T>) Sorts the elements in the entire List<T> using the specified System.Comparison<T>. (Inherited from List<T>.)
Public method Sort(IComparer<T>) Sorts the elements in the entire List<T> using the specified comparer. (Inherited from List<T>.)
Public method Sort(Int32, Int32, IComparer<T>) Sorts the elements in a range of elements in List<T> using the specified comparer. (Inherited from List<T>.)
Top

Overloaded method syntax

The Sort methods enable you to sort with the default comparer for the object type in the list, or specify a customer sort method.

List<T>.Sort()

Sorts the elements in the entire list using the default comparer of the object type held in the list.

List<T>.Sort M(Comparison<T> comparison)

Sorts the elements in the entire list using the specified comparer.

List<T>.Sort(IComparer<T> comparer)

Sorts the elements in the entire list using the specified System.Comparison<T>.

List<T>.Sort(Int32 index, Int32 count, IComparer<T> comparer)

Sorts the elements in a range of elements in list using the specified comparer.

Parameters

Parameter

Type

Description

comparison

Comparison<T>

The delegate method to use when comparing elements

comparer

IComparer<T>

The IComparer<T> implementation to use when comparing elements, or null to use the default comparer Comparer<T>.Default.

index

Int32

The zero-based starting index of the range to sort.

count

Int32

The length of the range to sort.


Exceptions

Exception

Condition

InvalidOperationException

comparer is not specified or null, and the default comparer Comparer<T>.Default cannot find implementation of the System.IComparable<T> generic interface or the System.IComparable interface for type T.

ArgumentNullException

comparison is null.

ArgumentException

The implementation of comparison or comparer caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.

-or-

index and count do not specify a valid range in the List<T>.

ArgumentOutOfRangeException

index is less than 0 or count is less than 0.

Show:
© 2014 Microsoft