📌  相关文章
📜  python根据单个列表的排序对多个列表进行排序 - Python代码示例

📅  最后修改于: 2022-03-11 14:47:24.549000             🧑  作者: Mango

代码示例1
# Example usage:
list_of_lists = [[4,5,1,3,2], ['s','n','a','k','e'], ['p','l','a','n','e']]
list(map(list, list(zip(*sorted(zip(*list_of_lists), key=lambda sublist_to_sort_by: sublist_to_sort_by[0])))))
--> [[1, 2, 3, 4, 5], ['a', 'e', 'k', 's', 'n'], ['a', 'e', 'n', 'p', 'l']]
# This is involved to explain. Best way to understand it is to test
#    the components of the function from the inside out.