Array API specification for sorting functions.
A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions.
- Positional parameters must be positional-only parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order.
- Optional parameters must be keyword-only arguments.
- Unless stated otherwise, functions must support the data types defined in {ref}
data-types.
(function-argsort)=
Returns the indices that sort an array x along a specified axis.
-
x: <array>
- input array.
-
axis: int
- axis along which to sort. If set to
-1, the function must sort along the last axis. Default:-1.
- axis along which to sort. If set to
-
descending: bool
- sort order. If
True, the returned indices sortxin descending order (by value). IfFalse, the returned indices sortxin ascending order (by value). Default:False.
- sort order. If
-
stable: bool
- sort stability. If
True, the returned indices must maintain the relative order ofxvalues which compare as equal. IfFalse, the returned indices may or may not maintain the relative order ofxvalues which compare as equal (i.e., the relative order ofxvalues which compare as equal is implementation-dependent). Default:True.
- sort stability. If
-
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.
- an array of indices. The returned array must have the same shape as
(function-sort)=
Returns a sorted copy of an input array x.
-
x: <array>
- input array.
-
axis: int
- axis along which to sort. If set to
-1, the function must sort along the last axis. Default:-1.
- axis along which to sort. If set to
-
descending: bool
- sort order. If
True, the array must be sorted in descending order (by value). IfFalse, the array must be sorted in ascending order (by value). Default:False.
- sort order. If
-
stable: bool
- sort stability. If
True, the returned array must maintain the relative order ofxvalues which compare as equal. IfFalse, the returned array may or may not maintain the relative order ofxvalues which compare as equal (i.e., the relative order ofxvalues which compare as equal is implementation-dependent). Default:True.
- sort stability. If
-
out: <array>
- a sorted array. The returned array must have the same data type and shape as
x.
- a sorted array. The returned array must have the same data type and shape as