dpnp.ndarray.argsort

method

ndarray.argsort(axis=-1, kind=None, order=None, *, descending=False, stable=None)

Return an ndarray of indices that sort the array along the specified axis.

Refer to dpnp.argsort for full documentation.

Parameters:
  • axis ({None, int}, optional) -- Axis along which to sort. If None, the array is flattened before sorting. The default is -1, which sorts along the last axis. Default: -1.

  • kind ({None, "stable", "mergesort", "radixsort"}, optional) -- Sorting algorithm. The default is None, which uses parallel merge-sort or parallel radix-sort algorithms depending on the array data type. Default: None.

  • descending (bool, optional) -- Sort order. If True, the array must be sorted in descending order (by value). If False, the array must be sorted in ascending order (by value). Default: False.

  • stable ({None, bool}, optional) -- Sort stability. If True, the returned array will maintain the relative order of a values which compare as equal. The same behavior applies when set to False or None. Internally, this option selects kind="stable". Default: None.

See also

dpnp.sort

Return a sorted copy of an array.

dpnp.argsort

Return the indices that would sort an array.

dpnp.lexsort

Indirect stable sort on multiple keys.

dpnp.searchsorted

Find elements in a sorted array.

dpnp.partition

Partial sort.

Examples

>>> import dpnp as np
>>> a = np.array([3, 1, 2])
>>> a.argsort()
array([1, 2, 0])
>>> a = np.array([[0, 3], [2, 2]])
>>> a.argsort(axis=0)
array([[0, 1],
       [1, 0]])