Given:
df = pd.DataFrame({'Outcome':['Pass', 'Fail', 'Pass', 'Fail', 'Fail'], 'Severity':['High', 'Medium', 'Low', 'Medium', 'High']})
Outcome Severity
0 Pass High
1 Fail Medium
2 Pass Low
3 Fail Medium
4 Fail High
Doing:
# Make your columns custom ordered categoricals:
df.Outcome = pd.Categorical(df.Outcome, ordered=True, categories=['Fail', 'Pass'])
df.Severity = pd.Categorical(df.Severity, ordered=True, categories=['Low', 'Medium', 'High'])
# Sort, the sort will follow the category order, instead of Alphabetical.
df = df.sort_values(['Outcome', 'Severity'], ascending=[True, False], ignore_index=True)
print(df)
Output:
Outcome Severity
0 Fail High
1 Fail Medium
2 Fail Medium
3 Pass High
4 Pass Low