dpnp.sort
- dpnp.sort(a, axis=-1, kind=None, order=None, *, stable=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 ({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.kind ({None, "stable", "mergesort", "radixsort"}, optional) -- Sorting algorithm. Default is
None, which is equivalent to"stable".stable ({None, bool}, optional) -- Sort stability. If
True, the returned array will maintain the relative order ofavalues which compare as equal. The same behavior applies when set toFalseorNone. Internally, this option selectskind="stable". Default:None.
- 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, anAxisErroris raised.Limitations
Parameters order is only supported with its default value. Otherwise
NotImplementedErrorexception will be raised. Sorting algorithms"quicksort"and"heapsort"are not supported.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]])