我正在打印一些列表,但這些值未排序。基於python中的單個列表對多個列表進行排序
for f, h, u, ue, b, be, p, pe, m, me in zip(filename, human_rating, rating_unigram, percentage_error_unigram, rating_bigram, percentage_error_bigram, rating_pos, percentage_error_pos, machine_rating, percentage_error_machine_rating):
print "{:>6s}{:>5.1f}{:>7.2f}{:>8.2f} {:>7.2f} {:>7.2f} {:>7.2f} {:>8.2f} {:>7.2f} {:>8.2f}".format(f,h,u,ue,b,be,p,pe,m,me)
根據'文件名'中的值排序所有這些列表的最佳方法是什麼?
所以,如果:
filename = ['f3','f1','f2']
human_rating = ['1','2','3']
etc.
然後排序將返回:
filename = ['f1','f2','f3']
human_rating = ['2','3','1']
etc.
的Python 3注:拉鍊在Python 3返回一個迭代器,使用列表,查看其內容, ' zipped = list(zip(filename,human_rating,...))' – 2017-08-24 13:53:21