I have a list of dictionaries with some strings containing artists and their albums (fetched from Spotify). I want to sort this dictionary by artist first and then by album. But I want to use a locale aware sort (German in my case).
I found out that I can sort a list of dictionaries with multiple key like so:
somelist.sort(key=lambda k: (k['artist'].lower(), k["album"].lower()))
.lower because I want a case insensitive sort.
This works fine for English named artists and albums, but not for none-English. I found also out that for locale aware sorts I can use somelist.sort(key=locale.strxfrm).
What I don't understand: How can I combine locale-aware AND multiple key sorts?