[Answered ]-How can I create a dictionary of two lists that preserves the order of the first list in the minimum number of queries?


You can use the dict like

# Create the dict for the movies object.
id_movies = dict([(m.id, m) for m in movies])

# Get the data in order.
order_movies = [id_movies[i] for i in movie_ids]

This way you will get the object in same order which you gave.


Leave a comment