views:

420

answers:

3

Do any one know which sorting algorithm is used by .net when we implement IComparer in our class?

+1  A: 

According to the MSDN, .NET uses QuickSort. By the way, the method absolutely doesn't depend on the comparer (as long as it's comparison-based), why should .NET therefore use a different method depending on whether you provide a custom comparer or not?

Konrad Rudolph
+6  A: 

QuickSort seems to be it.

The documentation on IComparer says

This interface is used in conjunction with the Array.Sort and Array.BinarySearch methods.

The Array.Sort documentation says

This method uses the QuickSort algorithm. This implementation performs 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.

bdukes
+3  A: 

You can always use the Reflector to open that bad boy up and look for yourself.

Kon
Unless you spoonfeed, stuff like this will be downvoted :(
leppie