sort
Return a sorted copy of an array along the given axis.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
axis | number | -1 | Axis along which to sort. Default is -1 (last axis). Use null to sort the flattened array. |
kind | string | 'quicksort' | Sorting algorithm. Accepted values: 'quicksort', 'mergesort', 'heapsort', 'stable'. 'stable' and 'mergesort' both use a stable sort. |
NDArray — A sorted copy of the input array.
argsort
Return the indices that would sort an array along the given axis.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
axis | number | -1 | Axis along which to sort. |
kind | string | 'quicksort' | Sorting algorithm ('quicksort', 'mergesort', 'heapsort', 'stable'). |
NDArray — Array of indices that sort the input along the given axis.
lexsort
Perform an indirect stable sort using a sequence of keys. The last key is the primary sort key, the second-to-last is the secondary key, and so on.| Name | Type | Default | Description |
|---|---|---|---|
keys | ArrayLike[] | — | Sequence of arrays to sort by. The last array is the primary sort key. All arrays must have the same length. |
NDArray — Array of indices that sort the data lexicographically.
partition
Rearrange elements such that the element at thekth position is where it would be in a fully sorted array. Elements before kth are all smaller, and elements after are all larger, but neither partition is necessarily sorted internally.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
kth | number | number[] | — | Index or indices of elements to partition around. |
axis | number | -1 | Axis along which to partition. |
NDArray — A partitioned copy of the array.
argpartition
Return indices that would partition an array. The element at thekth index in the returned order is in its final sorted position.
| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
kth | number | number[] | — | Index or indices to partition around. |
axis | number | -1 | Axis along which to partition. |
NDArray — Array of indices that partition the input.
sort_complex
Sort an array by real part first, then by imaginary part for ties. Always returns a complex-typed result.| Name | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. If not complex, it is cast to complex first. |
NDArray — Sorted complex array.