Answers for "sort list python and sort the other one according"

2

sort a list by values of another one python

numbers = [1, 2, 3]
letters = ['c', 'a', 'b']

#The numbers array sorted by the letters order
sorted_list = [number for letter, number in sorted(zip(letters, numbers))]

print(sorted_list)
#prints: [2, 3, 1]
Posted by: Guest on January-04-2021

Code answers related to "sort list python and sort the other one according"

Python Answers by Framework

Browse Popular Code Answers by Language