I want to benchmark np.argsort by comparing different sorting algorithms, that are ‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’ available in the np.argsort documentation. I was wondering how was the pivot chosen in the i.e. quicksort.
I found the source file for np.sort and the choice of pivot is clear there. However, I cannot find the file describing what is happening under the hood of the np.argsort. The reasonable assumption would be that the methods are performing the same, however, I would want to somehow verify it.
When calling
np.argsort(kind='quicksort')the call gets dispatched toPyArray_ArgSortand then tonpy_aquicksort(C source links):This also includes a choice of pivot identical to your link to
np.sort:Without having looked into it further, I assume this chooses the center element of the current partition as pivot.