Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.recarray.sort

recarray.sort(axis=-1,kind='quicksort',order=None)

Sort an array, in-place.

Parameters:

axis : int, optional

Axis along which to sort. Default is -1, which means sort along thelast axis.

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

Sorting algorithm. Default is ‘quicksort’.

order : str or list of str, optional

Whena is an array with fields defined, this argument specifieswhich fields to compare first, second, etc. A single field canbe specified as a string, and not all fields need be specified,but unspecified fields will still be used, in the order in whichthey come up in the dtype, to break ties.

See also

numpy.sort
Return a sorted copy of an array.
argsort
Indirect sort.
lexsort
Indirect stable sort on multiple keys.
searchsorted
Find elements in sorted array.
partition
Partial sort.

Notes

Seesort for notes on the different sorting algorithms.

Examples

>>>a=np.array([[1,4],[3,1]])>>>a.sort(axis=1)>>>aarray([[1, 4],       [1, 3]])>>>a.sort(axis=0)>>>aarray([[1, 3],       [1, 4]])

Use theorder keyword to specify a field to use when sorting astructured array:

>>>a=np.array([('a',2),('c',1)],dtype=[('x','S1'),('y',int)])>>>a.sort(order='y')>>>aarray([('c', 1), ('a', 2)],      dtype=[('x', '|S1'), ('y', '<i4')])

Previous topic

numpy.recarray.setflags

Next topic

numpy.recarray.squeeze

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

[8]ページ先頭

©2009-2025 Movatter.jp