sorting method

how much sorting method in c++??(5 is enough)
and give the explanation please..help!
how much sorting method in c++??(5 is enough)
What?

http://www.cplusplus.com/reference/algorithm/sort/
do you mean how many sorting method we have in c++?
please, explain what do you want
yup..how many ways of sorting in c++..
Can you define what a 'way of sorting' is?
You can declare your own comparing function and sort using it if this is what you mean. This implies that C++ has an infinite amount of 'ways of sorting'
selection sort, bubble sort, insertion sort, quick sort and heap sort
Those things are to be implemented by yourself, the standard sorting functions don't have to stick to a defined algorithm. C++ standards only say the complexity that algorithm should have.
There are only two sorting algorithms: std::sort() and std::stable_sort(). The difference is that the latter guarantees that elements of the same value will maintain their relative ordering.
For example, [2,1,2,3] will become [1,2,2,3], and never [1,2,2,3].
Both algorithms have a guaranteed best-case complexity of O(n log n). std::sort() has no guaranteed worst-case complexity, but it will never be above O(n2). std::stable_sort() has a guaranteed worst-case complexity of O(n log2 n).
Last edited on
What about std::heap_sort() (or whatever it's called) or qsort (from C)?
http://www.cplusplus.com/reference/algorithm/sort_heap/
Yeah, that's another one, but I have no idea what it does.
It's a sort in place algorithm to take a heap (as an array) and turn it into a sorted array. I'm guessing it's faster than a normal sorting algorithm.
Topic archived. No new replies allowed.