Yes, this is what I've learned in my algorithms classes, and this is also how sort is implemented in the C++ STL. From Wikipedia:
The June 2000 SGI C++ Standard
Template Library stl_algo.h
implementation of unstable sort uses
the Musser introsort approach with the
recursion depth to switch to heapsort
passed as a parameter, median-of-3
pivot selection and the Sedgewick
final insertion sort pass. The element
threshold for switching to the simple
insertion sort was 16.
I did some informal performance tests last year and C++ STL std::sort was about twice as fast as Array.Sort in .NET. I don't know how .NET Array.Sort is implemented, but in .NET, an access in an array requires a bounds check, unlike in C++, which could largely account for the performance difference.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…