Answers for "sort list with respect to another list"

0

sort list with respect to another list

list1 = [[1,1],[1,2],[1],[2,2]]
list2 = [2, 3, 1, 4]

zipped_lists = zip(list1, list2)
sorted_pairs = sorted(zipped_lists)

tuples = zip(*sorted_pairs)
c,v = [ list(tuple) for tuple in  tuples]
print(c)
Posted by: Guest on August-18-2020

Code answers related to "sort list with respect to another list"

Browse Popular Code Answers by Language