Reputation:
I want to sort the list2 by using list1 l
ist1 = [7, 9, 12, 1, 4, 7] list2 = ['p','e','b','a','y','i']
the output should be
['a','y','p','i','e','b']
the p has the pair with 7 of smaller index
Upvotes: 1
Views: 35
Reputation: 1012
[item[1] for item in sorted(zip(list1,list2))]
Upvotes: 2