I'm not even sure what to call this, so it's difficult to search for. I have, for example,
people = [
{"age": 22, "first": "John", "last": "Smith"},
{"age": 22, "first": "Jane", "last": "Doe"},
{"age": 41, "first": "Brian", "last": "Johnson"},
]
And I want something like
people_by_age = {
22: [
{"first": "John", "last": "Smith"},
{"first": "Jane", "last": "Doe"},
],
41: [
{"first": "Brian", "last": "Johnson"}
]
}
What's the cleanest way to do this in Python 2?