Return copy of 'arr' sorted along the given axis.
Overview
Perform an inplace sort along the given axis using the algorithm specified by the kind keyword.
Signature
Function: | sort (arr) | |
Method: | arr. sort () |
Parameters
- arr : array
- Array to be sorted.
- axis : {None, int} optional
- Axis along which to sort. None indicates that the flattened array should be used.
- kind : {'quicksort', 'mergesort', 'heapsort'}, optional
- Sorting algorithm to use. See: Notes
- order : {None, list type}, optional
- When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. Not all fields need be specified.
Returns
sorted_array : array of same type as a
See Also
argsort : Indirect sort.
lexsort : Indirect stable sort on multiple keys.
searchsorted : Find keys in sorted array.
Notes
The various sorts are characterized by average speed, worst case performance, need for work space, and whether they are stable. A stable sort keeps items with the same key in the same relative order. The three available algorithms have the following properties:
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 All the sort algorithms make temporary copies of the data when the sort is not along the last axis. Consequently, sorts along the last axis are faster and use less space than sorts along other axis.
category
NumpyDocstrings/core