argsort¶
- argsort(x: array, /, *, axis: int = -1, descending: bool = False, stable: bool = True) array¶
Returns the indices that sort an array
xalong a specified axis.- Parameters:
x (array) – input array. Should have a real-valued data type.
axis (int) – axis along which to sort. A valid axis must be an integer on the interval
[-N, N), whereNis the number of axes inx. If an axis is specified as a negative integer, the function must determine the axis along which to perform the operation by counting backward from the last axis (where-1refers to the last axis). If provided an invalid axis, the function must raise an exception. Default:-1.descending (bool) – sort order. If
True, the returned indices must sortxin descending order (by value). IfFalse, the returned indices must sortxin ascending order (by value). Default:False.stable (bool) – sort stability. If
True, the returned indices must maintain the relative order ofxvalues which compare as equal. IfFalse, the returned indices may maintain the relative order ofxvalues which compare as equal (i.e., the relative order ofxvalues which compare as equal is implementation-dependent). Default:True.
- Returns:
out (array) – an array of indices. The returned array must have the same shape as
x. The returned array must have the default array index data type.
Notes
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see Complex Number Ordering).