简体   繁体   中英

Python: How to sort a list by the max of each element?

L=[[a,b],[c,d],[e,f],...]

我想按max(a,b),max(c,d),max(e,f)等对它进行排序。

您可以提供自定义key函数来sort

L.sort(key=max)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM