This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / ma / core / argsort

function

numpy.ma.core:argsort

source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :7197

Signature

def   argsort ( a axis = <no value> kind = None order = None endwith = True fill_value = None * stable = None )

Summary

Return an ndarray of indices that sort the array along the specified axis. Masked values are filled beforehand to fill_value.

Parameters

axis : int, optional

Axis along which to sort. If None, the default, the flattened array is used.

kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional

The sorting algorithm used.

order : str or list of str, optional

When a is an array with fields defined, this argument specifies which fields to compare first, second, etc. Not all fields need be specified.

endwith : {True, False}, optional

Whether missing values (if any) should be treated as the largest values (True) or the smallest values (False) When the array contains unmasked values at the same extremes of the datatype, the ordering of these values and the masked values is undefined.

fill_value : scalar or None, optional

Value used internally for the masked values. If fill_value is not None, it supersedes endwith.

stable : bool, optional

Only for compatibility with np.argsort. Ignored.

Returns

index_array : ndarray, int

Array of indices that sort a along the specified axis. In other words, a[index_array] yields a sorted a.

Notes

See sort for notes on the different sorting algorithms.

Examples

import numpy as np
a = np.ma.array([3,2,1], mask=[False, False, True])
a
a.argsort()

See also

lexsort

Indirect stable sort with multiple keys.

ma.MaskedArray.sort

Describes sorting algorithms used.

numpy.ndarray.sort

Inplace sort.

Aliases

  • numpy.ma.argsort