# 如何在python中对多个列表进行排序

``````def age(last,name,birthday):
ages=['32','21','35']
lasts=['Poquette','Garufi','Rim']
ctr=1
"""I tried the line below but it gives me error! error message: ages,lasts,names = zip(*sorted(zip(ages,lasts,names)))
ValueError: not enough values to unpack (expected 3, got 0)
"""
ages,lasts,names = zip(*sorted(zip(ages,lasts,names)))

for bday in birthday:
my_date = bday
b_date = datetime.strptime(my_date, '%m/%d/%Y')
age=("%d" % ((datetime.today() - b_date).days / 365))
ages.append(age)
for l in last:
lasts.append(l)
for n in name:
names.append(n)
# Iwant this to be sorted by age
for a,l,n in zip(ages,lasts,names):
print(f"{ctr} Employee name {l}, {n} Age:{a}")
ctr+=1
``````

``````for i in range(len(ages)):
# Find the minimum element in remaining
# unsorted array
min_idx = i
for j in range(i+1, len(ages)):
if ages[min_idx] > ages[j]:
min_idx = j

# Swap the found minimum element with
# the first element
# and also remining data
ages[i], ages[min_idx] = ages[min_idx], ages[i]
names[i], names[min_idx] = names[min_idx], names[i]
lasts[i], lasts[min_idx] = lasts[min_idx], lasts[i]

# Hence data is sorted by age
``````

bquos

``````ages=['32','21','35']
lasts=['Poquette','Garufi','Rim']

ages,lasts,names = zip(*sorted(zip(ages,lasts,names)))
print(ages,lasts,names)
``````

``````z = zip(ages,lasts,names)
print(list(z))
ages,lasts,names = zip(*sorted(z))
print(ages,lasts,names)
``````

[（''21'，'Garufi'，'Meaghan'），（'32'，'Poquette'，'Mattie'），（'35'，'Rim'，'Gladys'）]      追溯（最近一次通话）：      文件“ c：/ Users / * / Desktop / Test.py”，第9行      年龄，姓氏，名称= zip（* sorted（z））      ValueError：没有足够的值可解包（预期3，得到0）