import pandas as pd
data = {
"age": [50, 40, 30, 40, 20, 10, 30],
"qualified": [True, False, False, False, False, True, True]
}
idx = ["Mary", "Sally", "Emil", "Tobias", "Linus", "John", "Peter"]
df = pd.DataFrame(data, index = idx)
newdf = df.sort_index()
print(newdf)
age qualified Emil 30 False John 10 True Linus 20 False Mary 50 True Peter 30 True Sally 40 False Tobias 40 False