5858
5959
6060def _wrap_sort_argsort (
61- a , _sorting_fn , axis = - 1 , kind = None , order = None , stable = True
61+ a ,
62+ _sorting_fn ,
63+ axis = - 1 ,
64+ kind = None ,
65+ order = None ,
66+ descending = False ,
67+ stable = True ,
6268):
6369 """Wrap a sorting call from dpctl.tensor interface."""
6470
@@ -83,11 +89,15 @@ def _wrap_sort_argsort(
8389 axis = - 1
8490
8591 axis = normalize_axis_index (axis , ndim = usm_a .ndim )
86- usm_res = _sorting_fn (usm_a , axis = axis , stable = stable , kind = kind )
92+ usm_res = _sorting_fn (
93+ usm_a , axis = axis , descending = descending , stable = stable , kind = kind
94+ )
8795 return dpnp_array ._create_from_usm_ndarray (usm_res )
8896
8997
90- def argsort (a , axis = - 1 , kind = None , order = None , * , stable = None ):
98+ def argsort (
99+ a , axis = - 1 , kind = None , order = None , * , descending = False , stable = None
100+ ):
91101 """
92102 Returns the indices that would sort an array.
93103
@@ -100,13 +110,21 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=None):
100110 axis : {None, int}, optional
101111 Axis along which to sort. If ``None``, the array is flattened before
102112 sorting. The default is ``-1``, which sorts along the last axis.
113+ Default: ``-1``.
103114 kind : {None, "stable", "mergesort", "radixsort"}, optional
104- Sorting algorithm. Default is ``None``, which is equivalent to
105- ``"stable"``.
115+ Sorting algorithm. The default is ``None``, which uses parallel
116+ merge-sort or parallel radix-sort algorithms depending on the array
117+ data type.
118+ Default: ``None``.
119+ descending : bool, optional
120+ Sort order. If ``True``, the array must be sorted in descending order
121+ (by value). If ``False``, the array must be sorted in ascending order
122+ (by value).
123+ Default: ``False``.
106124 stable : {None, bool}, optional
107- Sort stability. If ``True``, the returned array will maintain
108- the relative order of ``a`` values which compare as equal.
109- The same behavior applies when set to ``False`` or ``None``.
125+ Sort stability. If ``True``, the returned array will maintain the
126+ relative order of `a` values which compare as equal. The same behavior
127+ applies when set to ``False`` or ``None``.
110128 Internally, this option selects ``kind="stable"``.
111129 Default: ``None``.
112130
@@ -130,7 +148,6 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=None):
130148 Otherwise ``NotImplementedError`` exception will be raised.
131149 Sorting algorithms ``"quicksort"`` and ``"heapsort"`` are not supported.
132150
133-
134151 See Also
135152 --------
136153 :obj:`dpnp.ndarray.argsort` : Equivalent method.
@@ -171,7 +188,13 @@ def argsort(a, axis=-1, kind=None, order=None, *, stable=None):
171188 """
172189
173190 return _wrap_sort_argsort (
174- a , dpt .argsort , axis = axis , kind = kind , order = order , stable = stable
191+ a ,
192+ dpt .argsort ,
193+ axis = axis ,
194+ kind = kind ,
195+ order = order ,
196+ descending = descending ,
197+ stable = stable ,
175198 )
176199
177200
@@ -215,7 +238,7 @@ def partition(x1, kth, axis=-1, kind="introselect", order=None):
215238 return call_origin (numpy .partition , x1 , kth , axis , kind , order )
216239
217240
218- def sort (a , axis = - 1 , kind = None , order = None , * , stable = None ):
241+ def sort (a , axis = - 1 , kind = None , order = None , * , descending = False , stable = None ):
219242 """
220243 Return a sorted copy of an array.
221244
@@ -228,13 +251,21 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=None):
228251 axis : {None, int}, optional
229252 Axis along which to sort. If ``None``, the array is flattened before
230253 sorting. The default is ``-1``, which sorts along the last axis.
254+ Default: ``-1``.
231255 kind : {None, "stable", "mergesort", "radixsort"}, optional
232- Sorting algorithm. Default is ``None``, which is equivalent to
233- ``"stable"``.
256+ Sorting algorithm. The default is ``None``, which uses parallel
257+ merge-sort or parallel radix-sort algorithms depending on the array
258+ data type.
259+ Default: ``None``.
260+ descending : bool, optional
261+ Sort order. If ``True``, the array must be sorted in descending order
262+ (by value). If ``False``, the array must be sorted in ascending order
263+ (by value).
264+ Default: ``False``.
234265 stable : {None, bool}, optional
235- Sort stability. If ``True``, the returned array will maintain
236- the relative order of ``a`` values which compare as equal.
237- The same behavior applies when set to ``False`` or ``None``.
266+ Sort stability. If ``True``, the returned array will maintain the
267+ relative order of `a` values which compare as equal. The same behavior
268+ applies when set to ``False`` or ``None``.
238269 Internally, this option selects ``kind="stable"``.
239270 Default: ``None``.
240271
@@ -265,7 +296,7 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=None):
265296 Examples
266297 --------
267298 >>> import dpnp as np
268- >>> a = np.array([[1,4],[3,1]])
299+ >>> a = np.array([[1, 4], [3, 1]])
269300 >>> np.sort(a) # sort along the last axis
270301 array([[1, 4],
271302 [1, 3]])
@@ -278,7 +309,13 @@ def sort(a, axis=-1, kind=None, order=None, *, stable=None):
278309 """
279310
280311 return _wrap_sort_argsort (
281- a , dpt .sort , axis = axis , kind = kind , order = order , stable = stable
312+ a ,
313+ dpt .sort ,
314+ axis = axis ,
315+ kind = kind ,
316+ order = order ,
317+ descending = descending ,
318+ stable = stable ,
282319 )
283320
284321
0 commit comments