bundles / numpy latest / numpy / ma / core / MaskedArray / sort
function
numpy.ma.core:MaskedArray.sort
source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py:5773
Signature
def sort(self, axis = -1, kind = None, order = None, endwith = True, fill_value = None, *, stable = False)Summary
Sort the array, in-place
Parameters
a: array_likeArray to be sorted.
axis: int, optionalAxis along which to sort. If None, the array is flattened before sorting. The default is -1, which sorts along the last axis.
kind: {'quicksort', 'mergesort', 'heapsort', 'stable'}, optionalThe sorting algorithm used.
order: list, optionalWhen a is a structured array, this argument specifies which fields to compare first, second, and so on. This list does not need to include all of the fields.
endwith: {True, False}, optionalWhether missing values (if any) should be treated as the largest values (True) or the smallest values (False) When the array contains unmasked values sorting at the same extremes of the datatype, the ordering of these values and the masked values is undefined.
fill_value: scalar or None, optionalValue used internally for the masked values. If
fill_valueis not None, it supersedesendwith.stable: bool, optionalOnly for compatibility with
np.sort. Ignored.
Notes
See sort for notes on the different sorting algorithms.
Examples
import numpy as np a = np.ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0]) a.sort() a
a = np.ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0]) a.sort(endwith=False) a
a = np.ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0]) a.sort(endwith=False, fill_value=3) a
See also
- argsort
Indirect sort.
- lexsort
Indirect stable sort on multiple keys.
- numpy.ndarray.sort
Method to sort an array in-place.
- searchsorted
Find elements in a sorted array.
Aliases
numpy.ma.MaskedArray.sort