Could anyone please advise when implementing something like IComparable in .NET what sorting algorithm does .NET use to actually sort the underlying data? Also is the algorithm used customizable or selectable?
There are two biggies.
Array.Sort
(which sorts an array in-place) uses an unstable Quicksort.
This is the same implementation used internally by List<T>.Sort
, according to the MSDN documentation:
This method uses
Array.Sort
, which uses the QuickSort algorithm.
The Enumerable.OrderBy<TSource, TKey>
method (which sorts a copy of an input sequence) uses a stable Quicksort.
As far as I know, these are the only two sorting implementations in the .NET BCL.