Sort list of dictionaries by another list. I have got list with dictionaries (IN) and I want to sort this by another list (sortValue).
IN
sortValue
Build a dictionary that maps IDs to the dictionary with that ID and then go through your sortValue list and pick the dictionary for each ID value:
id2dict = dict((d['id'], d) for d in IN) OUT = [id2dict[x] for x in sortValue]