Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.ma.sort

numpy.ma.sort(a,axis=-1,kind='quicksort',order=None,endwith=True,fill_value=None)[source]

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 beforesorting. The default is -1, which sorts along the last axis.

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

Sorting algorithm. Default is ‘quicksort’.

order : list, optional

Whena is a structured array, this argument specifies which fieldsto compare first, second, and so on. This list does not need toinclude all of the fields.

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_value : {var}, optional

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

Returns:

sorted_array : ndarray

Array of the same type and shape asa.

See also

ndarray.sort
Method to sort an array in-place.
argsort
Indirect sort.
lexsort
Indirect stable sort on multiple keys.
searchsorted
Find elements in a sorted array.

Notes

Seesort for notes on the different sorting algorithms.

Examples

>>>a=ma.array([1,2,5,4,3],mask=[0,1,0,1,0])>>># Default>>>a.sort()>>>print(a)[1 3 5 -- --]
>>>a=ma.array([1,2,5,4,3],mask=[0,1,0,1,0])>>># Put missing values in the front>>>a.sort(endwith=False)>>>print(a)[-- -- 1 3 5]
>>>a=ma.array([1,2,5,4,3],mask=[0,1,0,1,0])>>># fill_value takes over endwith>>>a.sort(endwith=False,fill_value=3)>>>print(a)[1 -- -- 3 5]

Previous topic

numpy.ma.argsort

Next topic

numpy.ma.diag

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp