python中两组数据如何根据其中一组数据的内容进行排序

现在有两个列表的数据,把list1的按降序排序或升序排序,list2的排序也跟着变
list1 = [22,3,5,2,4,7,6,1,8,9,20,16,11,10,12,13,14,15,17,21,18,19]
list2 = [b,a,g,k,c,a,d,a,zc,sd,fgh,jgjh,ads,rrt,fhg,fhg,f,y,rf,rf,e,2sw2]
请问如何才能做到呢??

list1 = [22, 3, 5, 2, 4, 7, 6, 1, 8, 9, 20, 16, 11, 10, 12, 13, 14, 15, 17, 21, 18, 19]
list2 = ['b', 'a', 'g', 'k', 'c', 'a', 'd', 'a', 'zc', 'sd', 'fgh', 'jgjh', 'ads', 'rrt', 'fhg', 'fhg', 'f', 'y', 'rf',
         'rf', 'e', '2sw2']
assert len(list1) == len(list2)
list3 = []
for i in range(len(list1)):
    list3.append([list1[i], list2[i]])
list3.sort(key=lambda x: x[0])
list4 = []
list5 = []
for i in range(len(list3)):
    list4.append(list3[i][0])
    list5.append(list3[i][1])
print(list3)
print(list4)
print(list5)

有帮助望采纳

list1 = [3,4,1,5,2]
list2 = ['a','b','c','e','f']

# res:[(3, 'a'), (4, 'b'), (1, 'c'), (5, 'e'), (2, 'f')]
res=list(zip(list1,list2))
# [(1, 'c'), (2, 'f'), (3, 'a'), (4, 'b'), (5, 'e')]
sorted(res,key=lambda x:x[0])