I am using Google's directions API to get an optimized routes list given several points. It returns an array with the right order for the points:
[4, 0, 6, 7, 1, 3, 5, 2]
I want to use that array to order my points as well, which is an array of objects:
[obj0, obj1, obj2, obj3, obj4, obj5, obj6, obj7]
And get as a result:
[obj4, obj0, obj6, obj7, obj1, obj3, obj5, obj2]
What can I do in order to accomplish this?