Source code for arkouda.array_api._sorting_functions
from__future__importannotationsfrom._array_objectimportArrayfrom._dtypesimport_real_numeric_dtypesfrom._manipulation_functionsimportflipimportarkoudaasak# Note: the descending keyword argument is new in this function
[docs]defargsort(x:Array,/,*,axis:int=-1,descending:bool=False,stable:bool=True)->Array:""" Array API compatible wrapper for :py:func:`np.argsort <numpy.argsort>`. See its docstring for more information. """ifaxis==-1:axis=x.ndim-1a=Array._new(ak.argsort(x._array,axis=axis))ifdescending:flip(a,axis=axis)returna
# Note: the descending keyword argument is new in this function
[docs]defsort(x:Array,/,*,axis:int=-1,descending:bool=False,stable:bool=True)->Array:""" Array API compatible wrapper for :py:func:`np.sort <numpy.sort>`. See its docstring for more information. """ifx.dtypenotin_real_numeric_dtypes:raiseTypeError("Only real numeric dtypes are allowed in sort")res=ak.sort(x._array)returnArray._new(res)