1. 同时按照一个list的大小排序两个list
def return_sorted_list(cclass): namelist = [] numlist = [] for cat in cclass.cat: namelist.append(cat.catName) numlist.append(cat.catNum) #排序 name_num_zip = zip(namelist,numlist) sorted_name_num_zip = sorted(name_num_zip,key=lambda x:x[1]) result = zip(*sorted_name_num_zip) namelist, numlist = [list(x) for x in result] namelist.reverse() numlist.reverse() return namelist,numlist
标签:namelist,name,zip,Python,Tricks,num,sorted,numlist From: https://www.cnblogs.com/traceofMind/p/17823557.html