dpnp.sort

dpnp.sort(a, axis=-1, kind=None, order=None)[source]

Return a sorted copy of an array.

For full documentation refer to numpy.sort.

Parameters:
  • a ({dpnp.ndarray, usm_ndarray}) -- Array to be sorted.

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

  • kind ({None, "stable"}, optional) -- Default is None, which is equivalent to "stable". Unlike in NumPy any other options are not accepted here.

Returns:

out -- Sorted array with the same type and shape as a.

Return type:

dpnp.ndarray

Notes

For zero-dimensional arrays, if axis=None, output is the input array returned as a one-dimensional array. Otherwise, an AxisError is raised.

Limitations

Parameters order is only supported with its default value. Parameters kind can only be None or "stable" which are equivalent. Otherwise NotImplementedError exception will be raised.

See also

dpnp.ndarray.sort

Sort an array in-place.

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([[1,4],[3,1]])
>>> np.sort(a)                # sort along the last axis
array([[1, 4],
       [1, 3]])
>>> np.sort(a, axis=None)     # sort the flattened array
array([1, 1, 3, 4])
>>> np.sort(a, axis=0)        # sort along the first axis
array([[1, 1],
       [3, 4]])