Given the DataFrame:
import pandas as pd df = pd.DataFrame([6, 4, 2, 4, 5], index=[2, 6, 3, 4, 5], columns=[\'A\'])
Results in:
<
You can sort by index and then by column A using kind='mergesort'.
kind='mergesort'
This works because mergesort is stable.
res = df.sort_index().sort_values('A', kind='mergesort')
Result:
A 3 2 4 4 6 4 5 5 2 6