numpy.ma.MaskedArray.argsort#

method

ma.MaskedArray.argsort(axis=<novalue>,kind=None,order=None,endwith=True,fill_value=None,*,stable=False)[source]#

Return an ndarray of indices that sort the array along thespecified axis. Masked values are filled beforehand tofill_value.

Parameters:
axisint, optional

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

kind{‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’}, optional

The sorting algorithm used.

orderlist, optional

Whena is an array with fields defined, this argument specifieswhich fields to compare first, second, etc. Not all fields need bespecified.

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 thedatatype, the ordering of these values and the masked values isundefined.

fill_valuescalar or None, optional

Value used internally for the masked values.Iffill_value is not None, it supersedesendwith.

stablebool, optional

Only for compatibility withnp.argsort. Ignored.

Returns:
index_arrayndarray, int

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

See also

ma.MaskedArray.sort

Describes sorting algorithms used.

lexsort

Indirect stable sort with multiple keys.

numpy.ndarray.sort

Inplace sort.

Notes

Seesort for notes on the different sorting algorithms.

Examples

>>>importnumpyasnp>>>a=np.ma.array([3,2,1],mask=[False,False,True])>>>amasked_array(data=[3, 2, --],             mask=[False, False,  True],       fill_value=999999)>>>a.argsort()array([1, 0, 2])