Python中文
首页
教程
问答
标签
搜索
登录
注册
如何在python中对python二维数组排序
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在尝试用python制作排行榜,我有以下建议: <code>points = [("Bob",12),("Steve",7),("Alice",9)]</code> 我试图将其分为以下几点: <code>points = [("Bob",12),("Alice",9),("Steve",7)]</code> 我将如何通过编程实现这一点</p> <p>我试过了 <code>sorteddata = sorted(data,key=itemgetter(1))</code> 无济于事</p> <p>提前谢谢-埃文</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>您可以这样做:-</p> <pre><code>pts = list(points) pts.sort(key=lambda x:x[1], reverse=True) </code></pre> <p>输出:-</p> <pre><code>[('Bob', 12), ('Alice', 9), ('Steve', 7)] </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何用强化学习更新函数逼近中的权重?
4 回答
如何用归并排序计算倒数?
8 回答
如何用当前数据拟合正弦波?
7 回答
如何用当前页面的值填充表单?
6 回答
如何用彩色地图在2dpython直方图中勾勒出箱子的轮廓?
10 回答
如何用彩色地图给等高线标签上色?
3 回答
如何用彩色打印到控制台?
2 回答
如何用彩色条绘制2d直方图,在Python中显示第三个变量的平均值?
5 回答
如何用彩色条绘制直方图,其中的颜色应与xaxis中的值一致?
8 回答
如何用彩色贴图填充曲线和原始边之间的区域?
10 回答
如何用循环分割数组并对其应用操作?
9 回答
如何用循环创建多个子集的数据帧
7 回答
如何用循环和递归实现求和
1 回答
如何用循环填充数组?
6 回答
如何用循环当前引用的位置更新变量?
1 回答
如何用循环求这个级数的和
5 回答
如何用循环解这个方程?
5 回答
如何用循环语句逐个读取数据帧中的数据?
3 回答
如何用循环除法?(Python)
8 回答
如何用感知一致性对HSV空间进行采样
2 回答