Answers for "sort list of list by particular element"

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 of list by particular element"

Python Answers by Framework

Browse Popular Code Answers by Language