[Cs3] sorting
Mikhail Nesterenko
mikhail at cs.kent.edu
Mon Oct 12 14:28:02 EDT 2015
CS3 students,
Regarding stl::sort(). It uses unspecified O(NlogN) sorting
algorithm. The only thing that is modifiable is the callback that
specifies how to compare individual elements. For example, this sorts
the elements in decreasing rather than increasing order.
sort(w.begin(), w.end(), std::greater<int>());
The sorting algorithm itself is not modifiable. Recent implementations
of STL use introsort:
https://en.wikipedia.org/wiki/Sort_(C%2B%2B)
Thanks,
--
Mikhail
More information about the cs3
mailing list