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

Method sort

numpy/ma/core.py:5677–5758  ·  view source on GitHub ↗

Sort the array, in-place Parameters ---------- a : array_like Array to be sorted. axis : int, optional Axis along which to sort. If None, the array is flattened before sorting. The default is -1, which sorts along the last

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

Source from the content-addressed store, hash-verified

5675 return d.argmax(axis, out=out, keepdims=keepdims)
5676
5677 def sort(self, axis=-1, kind=None, order=None,
5678 endwith=True, fill_value=None):
5679 """
5680 Sort the array, in-place
5681
5682 Parameters
5683 ----------
5684 a : array_like
5685 Array to be sorted.
5686 axis : int, optional
5687 Axis along which to sort. If None, the array is flattened before
5688 sorting. The default is -1, which sorts along the last axis.
5689 kind : {'quicksort', 'mergesort', 'heapsort', 'stable'}, optional
5690 The sorting algorithm used.
5691 order : list, optional
5692 When `a` is a structured array, this argument specifies which fields
5693 to compare first, second, and so on. This list does not need to
5694 include all of the fields.
5695 endwith : {True, False}, optional
5696 Whether missing values (if any) should be treated as the largest values
5697 (True) or the smallest values (False)
5698 When the array contains unmasked values sorting at the same extremes of the
5699 datatype, the ordering of these values and the masked values is
5700 undefined.
5701 fill_value : scalar or None, optional
5702 Value used internally for the masked values.
5703 If ``fill_value`` is not None, it supersedes ``endwith``.
5704
5705 Returns
5706 -------
5707 sorted_array : ndarray
5708 Array of the same type and shape as `a`.
5709
5710 See Also
5711 --------
5712 numpy.ndarray.sort : Method to sort an array in-place.
5713 argsort : Indirect sort.
5714 lexsort : Indirect stable sort on multiple keys.
5715 searchsorted : Find elements in a sorted array.
5716
5717 Notes
5718 -----
5719 See ``sort`` for notes on the different sorting algorithms.
5720
5721 Examples
5722 --------
5723 >>> a = np.ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0])
5724 >>> # Default
5725 >>> a.sort()
5726 >>> a
5727 masked_array(data=[1, 3, 5, --, --],
5728 mask=[False, False, False, True, True],
5729 fill_value=999999)
5730
5731 >>> a = np.ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0])
5732 >>> # Put missing values in the front
5733 >>> a.sort(endwith=False)
5734 >>> a

Callers 15

travis-sorter.pyFile · 0.80
commitstats.pyFile · 0.80
get_authorsFunction · 0.80
get_pull_requestsFunction · 0.80
find_process_filesFunction · 0.80
__repr__Method · 0.80
attrFunction · 0.80
test_sort_matrix_noneFunction · 0.80
configurationFunction · 0.80
sortFunction · 0.80
_makenames_listFunction · 0.80

Calls 1

argsortMethod · 0.95

Tested by 15

test_sort_matrix_noneFunction · 0.64
test_half_orderingMethod · 0.64
test_sort_bigendianMethod · 0.64
test_random_shuffleMethod · 0.64
test_attributesMethod · 0.64
assert_arg_sortedFunction · 0.64
test_sortMethod · 0.64
test_sort_unsignedMethod · 0.64