ArrayList.Sort Method (IComparer)
Sorts the elements in the entire ArrayList using the specified comparer.
Assembly: mscorlib (in mscorlib.dll)
abstract Sort : comparer:IComparer -> unit override Sort : comparer:IComparer -> unit
Use the IComparer interface. If you pass null for comparer, this method uses the IComparable implementation of each element. In this case, you must make sure that the objects contained in the list implement the IComparer interface or an exception will occur.method to sort a list of objects with a custom comparer that implements the
In addition, using the IComparable implementation means the list performs a comparison sort (also called 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. To perform a stable sort, you must implement a custom IComparer interface.
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.
Available since 10
Available since 1.1