The list of dictionaries must be reordered in the order of the values contained in the other list, as shown below.(In this case ["site"].)
The other list contains the values of the dictionary.
In the case of just dictionaries, it is easy to reorder them using comprehensions, etc., but I could not think of a way to reorder the dictionary lists.
How is it possible to reorder them in this way?
l = ["c", "b", "a"]
d = [
{"id": 1, "site": "a"},
{"id": 2, "site": "c"},
{"id": 3, "site": "b"}
]
↓
[
{"id": 2, "site": "c"},
{"id": 3, "site": "b"}
{"id": 1, "site": "a"},
]