57. Sort algorithm

Quicksort is a comparison sorting algorithm for elements of an array for which a total order is defined. When implemented well, it is significantly faster than merge sort or heap sort.

Although in worst-case scenarios the algorithm makes  comparisons (when the range is already sorted), on average the complexity is only . Quicksort is a divide and conquer algorithm; it partitions (divides) a large range into smaller ones and sorts them recursively. There are several partitioning schemes. In the implementation shown here, we ...

Get Modern C++: Efficient and Scalable Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.