larray.Array.indicesofsorted

Array.indicesofsorted(axis=None, ascending=True, kind='quicksort') Array[source]

Return the indices that would sort this array.

Performs an indirect sort along the given axis using the algorithm specified by the kind keyword. It returns an array of indices with the same axes as a that index data along the given axis in sorted order.

Parameters
axisint or str or Axis, optional

Axis along which to sort. This can be omitted if array has only one axis.

ascendingbool, optional

Sort values in ascending order. Defaults to True.

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

Sorting algorithm. Defaults to ‘quicksort’.

Returns
Array

Examples

>>> arr = Array([[1, 5], [3, 2], [0, 4]], "nat=BE,FR,IT; sex=M,F")
>>> arr
nat\sex  M  F
     BE  1  5
     FR  3  2
     IT  0  4
>>> arr.indicesofsorted('nat')
nat\sex  M  F
      0  2  1
      1  0  2
      2  1  0
>>> arr.indicesofsorted('nat', ascending=False)
nat\sex  M  F
      0  1  0
      1  0  2
      2  2  1