I've got a list of objects of the following format:
obj = [{"id": 39, "name":"bla"},{"id": 23, "name":"blabla"},{"id": 45, "name":"blabla"},{"id": 12, "name":"blabla"},{"id": 100, "name":"blabla"},...]
I also have a list of IDs (A
) defined as follows:
A = [23,39,45,...]
I need to sort obj
such that all the sorting reflects the order of A
- the first object is the one with key 23
, the second one with key 39
and so on.
I'm thinking of using zip
for this but not sure exactly how to do so - would I need to zip the two lists together and then sort the zipped list of tuples?