Possible Duplicate:
Sorting list of lists by a third list of specified non-sorted order
a = [{'id':1}, {'id':2}, {'id':3}]
b = [2,1,3]
What would be a good method to sort dict a by list b via the id property.
The result should look something like this
[{'id':2}, {'id':1}, {'id':3}]
No voodoo is required, as long as you can guarantee
bhas been populated with all theids ina:(I’m often told there’s an alternative to
lambdathat should be used nowadays, but this is still the clearest way I know for doing this)EDIT: Also note that this is nearly identical to this answer in the linked question.