How to sort a list of dictionaries where some labels for which I want to sort may be missing?
In particular, this list is from MPD and looks something like this:
[{'title':'Bad','album': 'XSCAPE','genre':'Pop'}, {'title': 'Down to', 'album': 'Money'}]
I would like to sort by genre, but note that the dictionary in the second element does not have a key for this.
Is there a built-in “Pythonic” method for this, or will I need to build my own sorting algorithm?
source
share