Which type of sorting is used in the std::sort()?

后端 未结 7 1221
无人共我
无人共我 2020-12-01 09:34

Can anyone please tell me that which type of sorting technique (bubble, insertion, selection, quick, merge, count...) is implemented in the std::sort() function

7条回答
  •  天命终不由人
    2020-12-01 09:46

    Just some empirical results:

    I translated a python script using numpy 1.9.2 sort to C++ using std::sort (VS2008 toolchain).

    I only get the same exact results in the python and C++ sides when I use numpy.sort argument kind='mergesort'. I get different relative ordering for elements with same key when kind='quicksort' or kind='heapsort'. So I guess that at least for the version of STL that comes with VS2008 std::sort uses mergesort.

提交回复
热议问题