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
AxisErroris raised.Limitations
Parameters order is only supported with its default value. Parameters kind can only be
Noneor"stable"which are equivalent. OtherwiseNotImplementedErrorexception will be raised.See also
dpnp.ndarray.sortSort an array in-place.
dpnp.argsortReturn the indices that would sort an array.
dpnp.lexsortIndirect stable sort on multiple keys.
dpnp.searchsortedFind elements in a sorted array.
dpnp.partitionPartial 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]])