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

Function sort

numpy/ma/core.py:7016–7054  ·  view source on GitHub ↗

Return a sorted copy of the masked array. Equivalent to creating a copy of the array and applying the MaskedArray ``sort()`` method. Refer to ``MaskedArray.sort`` for the full documentation See Also -------- MaskedArray.sort : equivalent method Examples ----

(a, axis=-1, kind=None, order=None, endwith=True, fill_value=None)

Source from the content-addressed store, hash-verified

7014argsort.__doc__ = MaskedArray.argsort.__doc__
7015
7016def sort(a, axis=-1, kind=None, order=None, endwith=True, fill_value=None):
7017 """
7018 Return a sorted copy of the masked array.
7019
7020 Equivalent to creating a copy of the array
7021 and applying the MaskedArray ``sort()`` method.
7022
7023 Refer to ``MaskedArray.sort`` for the full documentation
7024
7025 See Also
7026 --------
7027 MaskedArray.sort : equivalent method
7028
7029 Examples
7030 --------
7031 >>> import numpy.ma as ma
7032 >>> x = [11.2, -3.973, 0.801, -1.41]
7033 >>> mask = [0, 0, 0, 1]
7034 >>> masked_x = ma.masked_array(x, mask)
7035 >>> masked_x
7036 masked_array(data=[11.2, -3.973, 0.801, --],
7037 mask=[False, False, False, True],
7038 fill_value=1e+20)
7039 >>> ma.sort(masked_x)
7040 masked_array(data=[-3.973, 0.801, 11.2, --],
7041 mask=[False, False, False, True],
7042 fill_value=1e+20)
7043 """
7044 a = np.array(a, copy=True, subok=True)
7045 if axis is None:
7046 a = a.flatten()
7047 axis = 0
7048
7049 if isinstance(a, MaskedArray):
7050 a.sort(axis=axis, kind=kind, order=order,
7051 endwith=endwith, fill_value=fill_value)
7052 else:
7053 a.sort(axis=axis, kind=kind, order=order)
7054 return a
7055
7056
7057def compressed(x):

Callers 7

svdFunction · 0.90
test_testCIMethod · 0.90
test_indexingMethod · 0.90
test_sortMethod · 0.90
test_sort_flexibleMethod · 0.90
_medianFunction · 0.70

Calls 2

flattenMethod · 0.80
sortMethod · 0.80

Tested by 5

test_testCIMethod · 0.72
test_indexingMethod · 0.72
test_sortMethod · 0.72
test_sort_flexibleMethod · 0.72