I need sort this list of dictionaries:
[ {K: 1, B: 2, A: 3, Z: 4, ... } , ... ]
Ordering should be:
- K - descending
- B - descending
- A - ascending
- Z - ascending
I only found out how to sort all keys in ascending or descending (reverse=True
):
stats.sort(key=lambda x: (x['K'], x['B'], x['A'], x['Z']))
Can anybody help, how to sort in key-different ordering?