2👍
✅
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.
Source:stackexchange.com