I've been working with a long list of dicts for a while and can't seem to wrap my head around how to sort it the way I'd like. Here's a shorter example:
artist_movement = [
{'movement': 'Abstract Expressionism', 'artist': 'William Baziotes'},
{'movement': 'Modern Art', 'artist': 'Alexander Calder'},
{'movement': 'Abstract Expressionism', 'artist': 'Grace Hartigan'},
{'movement': 'Cubism', 'artist': 'Pablo Picasso'},
{'movement': 'Cubism', 'artist': 'Peter Blume'},
{'movement': 'Abstract Expressionism', 'artist': 'Norman Wilfred Lewis'},
{'movement': 'Modern Art', 'artist': 'Lucian Freud'}
]
I'd like to sort the artists by movement in in a similar way to this:
artist_by_movement = [
{'Abstract Expressionism':['William Baziotes', 'Grace Hartigan', 'Norman Wilfred Lewis']},
{'Modern Art':['Alexander Calder', 'Lucian Freud']},
{'Cubism':['Peter Blume', 'Pablo Picasso']}
]
Thanks for any help!