Is there a way to sort (and return) a dictionary by multiple values? The below returns the values in a list. I'd like to improve on the below and also return the keys so that the returned data structure is a sorted dictionary.
df = pd.DataFrame([[-1,1,-1,3,1,2]], index =
pd.date_range(start = '2022-02-07', periods =1, name = 'Date'))
df.columns = pd.MultiIndex.from_tuples((("IINN", "s"), ("IINN", "count"),
("GII", "s"), ("GII","count"),("HCM","s"), ("HCM", "count")))
dct={c:df[c] for c in df.columns.levels[0]}
sorted(dct.values(),key = lambda item: (item['s'][-1],item['count'][-1]), reverse=True)
[ s count
Date
2022-02-07 1 2,
s count
Date
2022-02-07 -1 3,
s count
Date
2022-02-07 -1 1]