I want to create a new list with the elements of a list, but sorted according to the values of another list.
Example:
list = [12, 17, 26, 28, 29, 33, 34, 37, 41, 43, 45, 64, 70]
index_list = [9, 10, 0, 1, 2, 6, 8, 7, 3, 5, 4, 11, 12]
the result should be:
final_list = [26, 28, 29, 41, 45, 43, 33, 37, 34, 12, 17, 64, 70]
I tried to do it with the insert method:
final_list = []
for i in range(len(list)):
final_list.insert(index_list[i], list[i])
print(final_list)
but the output is not correct:
[26, 28, 29, 41, 45, 12, 43, 17, 33, 34, 37, 64, 70]