Sorting
NumPy has several data sorting routines:
- The
sort()
function returns a sorted array - The
lexsort()
function performs sorting with a list of keys - The
argsort()
function returns the indices that will sort an array - The
ndarray
class has asort()
method that performs in-place sorting - The
msort()
function sorts an array along the first axis - The
sort_complex()
function sorts complex numbers by their real part and then their imaginary part
From this list, the argsort()
and sort()
functions are available as methods on NumPy arrays as well.