How can I sort a list of dictionary by two keys, in which the second key should be sorted in descending order. I have a list which contains a number of dictionaries, the format is:
result = [{'so':ABC,'so_value':123.0,'inv':'ADV-025'},
{'so':PQR,'so_value':19.0,'inv':'908025'}]
I want to sort the list by keys 'so' (ascending) and 'inv'(descending). How can I do this with itemgetter
in python?
EDIT:
I have tried the following but it will sort only by ascending order. result = sorted(result, key=itemgetter('so', 'inv'))