Return the integer indices that would sort the index.
Passed to numpy.ndarray.argsort.
Passed to numpy.ndarray.argsort.
Integer indices that would sort the index if used as an indexer.
See also
numpy.argsortSimilar method for NumPy arrays.
Index.sort_valuesReturn sorted copy of Index.
Examples
>>> idx = pd.Index(['b', 'a', 'd', 'c'])
>>> idx
Index(['b', 'a', 'd', 'c'], dtype='object')
>>> order = idx.argsort()
>>> order
array([1, 0, 3, 2])
>>> idx[order]
Index(['a', 'b', 'c', 'd'], dtype='object')
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.Index.argsort.html