News for hackers. Stuff that matters.
Re:Sorting in C++: 3 times faster than C by osolo on Saturday March 17, 2012 @09:26AM (#3717013)
Exactly. std::sort does NOT use quick sort. So all he's doing is comparing two different algorithms. It has nothing to do with C vs C++.
Re:Sorting in C++: 3 times faster than C by albertzeyer on Saturday March 17, 2012 @09:54AM (#3717066)
That's not exactly true. `std::sort` can use quick sort. It depends on the implementation.

As well as `qsort`. It is also not guaranteed to use quick sort.

E.g., here is the BSD qsort: http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/bsd...

Here is the glibc one: http://www.umcs.maine.edu/~chaw/200801/capstone/n/qsort.c

Re:Sorting in C++: 3 times faster than C by cygx on Saturday March 17, 2012 @09:54AM (#3717067)
The more relevant difference here is probably compile-time generic code which can take advantage of inlining vs run-time generic code which can't.

However, C compilers are smart enough to transform the latter into the former, but only if you let them.

Re:Sorting in C++: 3 times faster than C by archangel_one on Saturday March 17, 2012 @09:50AM (#3717054)
std::sort isn't guaranteed to use any particular algorithm, but IIRC quicksort fits the requirements and hence has been used in the past, even if introsort might be more common now.
Re:Sorting in C++: 3 times faster than C by steve-howard on Saturday March 17, 2012 @10:12AM (#3717103)
I believe said requirements were written to allow qsort.