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

Method argsort

numpy/ma/core.py:5511–5589  ·  view source on GitHub ↗

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 arra

(self, axis=np._NoValue, kind=None, order=None,
                endwith=True, fill_value=None)

Source from the content-addressed store, hash-verified

5509 return out
5510
5511 def argsort(self, axis=np._NoValue, kind=None, order=None,
5512 endwith=True, fill_value=None):
5513 """
5514 Return an ndarray of indices that sort the array along the
5515 specified axis. Masked values are filled beforehand to
5516 `fill_value`.
5517
5518 Parameters
5519 ----------
5520 axis : int, optional
5521 Axis along which to sort. If None, the default, the flattened array
5522 is used.
5523
5524 .. versionchanged:: 1.13.0
5525 Previously, the default was documented to be -1, but that was
5526 in error. At some future date, the default will change to -1, as
5527 originally intended.
5528 Until then, the axis should be given explicitly when
5529 ``arr.ndim > 1``, to avoid a FutureWarning.
5530 kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
5531 The sorting algorithm used.
5532 order : list, optional
5533 When `a` is an array with fields defined, this argument specifies
5534 which fields to compare first, second, etc. Not all fields need be
5535 specified.
5536 endwith : {True, False}, optional
5537 Whether missing values (if any) should be treated as the largest values
5538 (True) or the smallest values (False)
5539 When the array contains unmasked values at the same extremes of the
5540 datatype, the ordering of these values and the masked values is
5541 undefined.
5542 fill_value : scalar or None, optional
5543 Value used internally for the masked values.
5544 If ``fill_value`` is not None, it supersedes ``endwith``.
5545
5546 Returns
5547 -------
5548 index_array : ndarray, int
5549 Array of indices that sort `a` along the specified axis.
5550 In other words, ``a[index_array]`` yields a sorted `a`.
5551
5552 See Also
5553 --------
5554 ma.MaskedArray.sort : Describes sorting algorithms used.
5555 lexsort : Indirect stable sort with multiple keys.
5556 numpy.ndarray.sort : Inplace sort.
5557
5558 Notes
5559 -----
5560 See `sort` for notes on the different sorting algorithms.
5561
5562 Examples
5563 --------
5564 >>> a = np.ma.array([3,2,1], mask=[False, False, True])
5565 >>> a
5566 masked_array(data=[3, 2, --],
5567 mask=[False, False, True],
5568 fill_value=999999)

Callers 15

sortMethod · 0.95
_unique1dFunction · 0.45
intersect1dFunction · 0.45
in1dFunction · 0.45
find_duplicatesFunction · 0.45
join_byFunction · 0.45
histogramFunction · 0.45
interpFunction · 0.45
insertFunction · 0.45
ndarray_misc.pyFile · 0.45
fromnumeric.pyFile · 0.45
argsortFunction · 0.45

Calls 4

filledMethod · 0.95
_deprecate_argsort_axisFunction · 0.85
minimum_fill_valueFunction · 0.85
maximum_fill_valueFunction · 0.85

Tested by 2

test_argsortMethod · 0.36
test_stable_desc_argsortFunction · 0.36