Skip to main content
`Ctrl`+`K`

# pandas.api.extensions.ExtensionArray.argsort

ExtensionArray.argsort(*, ascending=True, kind='quicksort', na_position='last', **kwargs)

  Return the indices that would sort this array.

  This method computes the indices that would produce a sorted version of the array when used with indexing.

  Parameters:
    ascending bool, default True

      Whether the indices should result in an ascending or descending sort.

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

      Sorting algorithm.

    na_position{‘first’, ‘last’}, default ‘last’

      If `'first'`, put `NaN` values at the beginning. If `'last'`, put `NaN` values at the end.

    **kwargs

      Passed through to `numpy.argsort()`.

  Returns:
    np.ndarray[np.intp]

      Array of indices that sort `self`. If NaN values are contained, NaN values are placed at the end.

  See also

  `numpy.argsort`

    Sorting implementation used internally.

  Examples

      >>> arr = pd.array([3, 1, 2, 5, 4])
      >>> arr.argsort()
      array([1, 2, 0, 4, 3])