dpnp.ndarray.sort
method
- ndarray.sort(axis=-1, kind=None, order=None, *, descending=False, stable=None)
Sort an array in-place.
Refer to
dpnp.sortfor 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). IfFalse, 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 toFalseorNone. Internally, this option selectskind="stable".Default:
None.
See also
dpnp.sortReturn a sorted copy of an array.
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.
Note
axis in
dpnp.sortcould be integer orNone. IfNone, the array is flattened before sorting. However, axis indpnp.ndarray.sortcan 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]])