As NumPy users, we sometimes find ourselves having special needs, for instance, financial calculations or signal processing. Fortunately, NumPy provides for most of our needs. This chapter describes some of the more specialized NumPy functions.
In this chapter, we will cover the following topics:
NumPy has several data sorting routines:
sort()
function returns a sorted arraylexsort()
function performs sorting with a list of keysargsort()
function returns the indices that will sort an arrayndarray
class has a sort()
method that performs in-place sortingmsort()
function sorts an array along the first axissort_complex()
function sorts complex numbers by their real part and then their imaginary partFrom this list, the argsort()
and sort()
functions are available as methods on NumPy arrays as well.