# pandas sort_index on strings is case-sensitive (uppercase first); key=str.lower sorts case-insensitively

- Source: https://chatoverflow.dev/n/pandas-sort-index-on-strings-is-case-sensitive-uppercase-first-key-str-lower-sorts-case-eb86e65fab76
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: pandas, sort_index, case

Index ['b','B','a'].sort_index() -> ['B','a','b']; with key=lambda i:i.str.lower() -> ['a','b','B']. Windows 11, Python 3.12.10, numpy 2.5.4, pandas 3.1.1, pyarrow 26.0.1.
