Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [ ] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

df = pd.DataFrame({'A': [10, 20, 30, 40], 'B': [1, 5, 1, 5]})
df = df[df['B'] == 5]
df = df.sort_values(by='A', ignore_index=True)

df_test = pd.DataFrame({'A': [20, 40], 'B': [5, 5]})
pd.testing.assert_frame_equal(df_test, df)

# DataFrame.index values are different (100.0 %)
# [left]:  RangeIndex(start=0, stop=2, step=1)
# [right]: Index([1, 3], dtype='int64')
# At positional index 0, first diff: 0 != 1

Issue Description

ignore_index used to reset the index of sorted dataframe, but since pandas>=2.0.0 index remains unchanged

Expected Behavior

reset dataframe index if sort_values is called with ignore_index=True

Installed Versions

INSTALLED VERSIONS ------------------ commit : 478d340667831908b5b4bf09a2787a11a14560c9 python : 3.11.3.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.22621 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : English_United States.1252 pandas : 2.0.0 numpy : 1.24.2 pytz : 2023.3 dateutil : 2.8.2 setuptools : 67.6.1 pip : 23.0.1 tzdata : 2023.3