假设我有这些列表:
ids = [4, 3, 7, 8]
objects = [
{"id": 7, "text": "are"},
{"id": 3, "text": "how"},
{"id": 8, "text": "you"},
{"id": 4, "text": "hello"}
]
我怎样objects
才能对他们的ID匹配的顺序进行排序ids
?即得到这个结果:
objects = [
{"id": 4, "text": "hello"},
{"id": 3, "text": "how"},
{"id": 7, "text": "are"},
{"id": 8, "text": "you"}
]