dpnp.ndarray.sort

method

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

Sort an array in-place.

Refer to dpnp.sort for full documentation.

Parameters:
  • axis (int, optional) -- Axis along which to sort. 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.

Note

axis in dpnp.sort could be integer or None. If None, the array is flattened before sorting. However, axis in dpnp.ndarray.sort can only be integer since it sorts an array in-place.

Examples

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