list_1 = [2, 7, 4, 5, 6, 1, 3, 8, 9]
list_2 = [(1, 5), (2, 0), (3, 6), (4, 4), (5, 3), (6, 2), (7, 1), (8, 7), (9, 8)]
I want to reorder list list_2 such that the first element of each tuple follows the order specified by list_1, so:
list_2_ordered = [(2, 0), (7, 1), (4, 4), (5, 3), (6, 2), (1, 5), (3, 6), (8, 7), (9, 8)]
I try to use the map function to map filter over the list_1 as iterables (the general idea map(filter(lambda x,j : x[0]==j, list_2),list_1). But of course it doesn't work (I think due to type error). How can I do this with the least number of code lines?