diff options
author | Lakshay Garg <lakshayg@outlook.in> | 2018-03-23 00:09:58 +0530 |
---|---|---|
committer | Lakshay Garg <lakshayg@outlook.in> | 2018-03-23 03:40:17 +0530 |
commit | 864a431fd6047b1c26a7001bd2e3d989a5320e0f (patch) | |
tree | b57cdb4d8ec4f426561cfcad6b096857366f7790 /numpy/core/fromnumeric.py | |
parent | 2085cc7ff48f5ba6bdf39c27d0182d6593905fe5 (diff) | |
download | numpy-864a431fd6047b1c26a7001bd2e3d989a5320e0f.tar.gz |
add stablesort in np.sort and point to mergesort
Closes #10784
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 10256c3c0..ddf3314cf 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -764,7 +764,7 @@ def sort(a, axis=-1, kind='quicksort', order=None): axis : int or None, optional Axis along which to sort. If None, the array is flattened before sorting. The default is -1, which sorts along the last axis. - kind : {'quicksort', 'mergesort', 'heapsort'}, optional + kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional Sorting algorithm. Default is 'quicksort'. order : str or list of str, optional When `a` is an array with fields defined, this argument specifies @@ -797,9 +797,10 @@ def sort(a, axis=-1, kind='quicksort', order=None): =========== ======= ============= ============ ======= kind speed worst case work space stable =========== ======= ============= ============ ======= - 'quicksort' 1 O(n^2) 0 no - 'mergesort' 2 O(n*log(n)) ~n/2 yes - 'heapsort' 3 O(n*log(n)) 0 no + 'quicksort' 1 O(n^2) 0 no + 'mergesort' 2 O(n*log(n)) ~n/2 yes + 'stable' 2 O(n*log(n)) ~n/2 yes + 'heapsort' 3 O(n*log(n)) 0 no =========== ======= ============= ============ ======= All the sort algorithms make temporary copies of the data when @@ -886,7 +887,7 @@ def argsort(a, axis=-1, kind='quicksort', order=None): axis : int or None, optional Axis along which to sort. The default is -1 (the last axis). If None, the flattened array is used. - kind : {'quicksort', 'mergesort', 'heapsort'}, optional + kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional Sorting algorithm. order : str or list of str, optional When `a` is an array with fields defined, this argument specifies |