MCPcopy Create free account
hub / github.com/numpy/numpy / sort

Function sort

numpy/array_api/_sorting_functions.py:39–54  ·  view source on GitHub ↗

Array API compatible wrapper for :py:func:`np.sort `. See its docstring for more information.

(
    x: Array, /, *, axis: int = -1, descending: bool = False, stable: bool = True
)

Source from the content-addressed store, hash-verified

37
38# Note: the descending keyword argument is new in this function
39def sort(
40 x: Array, /, *, axis: int = -1, descending: bool = False, stable: bool = True
41) -> Array:
42 """
43 Array API compatible wrapper for :py:func:`np.sort <numpy.sort>`.
44
45 See its docstring for more information.
46 """
47 if x.dtype not in _real_numeric_dtypes:
48 raise TypeError("Only real numeric dtypes are allowed in sort")
49 # Note: this keyword argument is different, and the default is different.
50 kind = "stable" if stable else "quicksort"
51 res = np.sort(x._array, axis=axis, kind=kind)
52 if descending:
53 res = np.flip(res, axis=axis)
54 return Array._new(res)

Callers

nothing calls this directly

Calls 2

sortMethod · 0.80
_newMethod · 0.80

Tested by

no test coverage detected