在python中排序列表(sorting a list in python)
我正在尝试对列表中的列表进行排序:每个列表包含
[seq1,seq2,score]
,我想根据(seq1,seq2)的得分从最高得分到最低得分对列表L
进行排序,然后每个列表根据得分对每个(seq1,seq2)进行排名L=[ ['AA', 'CG', 0],['AA', 'AA', 4], ['CG', '--', -1]]
排序列表必须是:
L=[['AA', 'AA', 4], ['AA', 'CG', 0], ['CG', '--', -1]]
为队伍:
['AA', 'AA', 4] has rank 1 ['AA', 'CG', 0] has rank 2 ['CG', '--', -1] has rank 3
我该怎么做? 我试过了:
def getKey():/* to get the score from each list*/ scorelist=score()/*this is the list L*/ return scorelist[][2] def sort_list(): scorelist=score() p=sorted(s, key=getKey) return p
I am trying to sort lists on a list : each list contains
[seq1,seq2,score]
, I want to sort the listL
according to the score of (seq1,seq2) from the max score to the minimum score, then each list take a rank to each (seq1,seq2) according to the scoreL=[ ['AA', 'CG', 0],['AA', 'AA', 4], ['CG', '--', -1]]
the sorted list must be:
L=[['AA', 'AA', 4], ['AA', 'CG', 0], ['CG', '--', -1]]
for the ranks:
['AA', 'AA', 4] has rank 1 ['AA', 'CG', 0] has rank 2 ['CG', '--', -1] has rank 3
how can I do it? I tried:
def getKey():/* to get the score from each list*/ scorelist=score()/*this is the list L*/ return scorelist[][2] def sort_list(): scorelist=score() p=sorted(s, key=getKey) return p
原文:
更新时间:2022-08-21 15:08
最满意答案
查看Chris Coyier关于向三角形添加阴影的文章 。 它可能会帮助您实现这一目标。
Check out Chris Coyier's article on adding shadows to triangles. It might help you get this to work.
相关问答
更多-
使用UITextfield模拟twitter boostrap表单控件(simulate twitter boostrap form control using UITextfield)[2022-02-28]
可能最简单的方法是修改其背衬层: CALayer *theLayer = [theTextField layer]; [theLayer setBorderWidth:2.]; [theLayer setBorderColor:[[UIColor blueColor] CGColor]]; [theLayer setShadowColor:[[UIColor blueColor] CGColor]]; [theLayer setShadowOpacity:1.]; [theLayer setShadowRa ... -
我猜$运算符已经被mootools使用了。 要成为jQuery安全使用以下代码 I guess the $ operator is already used by moot ...
-
Twitter Boostrap - 获取警告信息以贴在页面顶部(Twitter Boostrap - getting alert message to stick to the top of the page)[2024-03-13]
如果要在所有其他元素之前插入元素,请使用.prepend() 。 这会将对象插入第一个子.append()而不是最后像.append() : success:function(msg) { if (msg == "fail") { $('body').prepend('...'); } } 将它放在页面的顶部,然后由你来确定它是你想要的地方。 此外,我还会看到使用模板系统或使用jQ ... -
.a和.b不是DOM中的元素。 只有当您尝试将鼠标悬停在工具提示上时,才会创建它们。 因此,只需将data-original-title更改为更新后的文本,而不是更改它。 例如: $('body').on('click', '.update', function() { $("a").attr("data-original-title", "10 x 20"); }); 更新小提琴 .a and .b ...
-
引导工具提示箭头颜色(Bootstrap tooltips arrow color)[2023-01-02]
改变border-color: red; border-right-color: red; Change the border-color: red; to border-right-color: red; -
您需要添加onsubmit事件处理程序以形成并向Google搜索发出URL请求,并向其添加查询参数,如下所示 你的表格 -
-
将window.load更改为文档就绪。 它快一点。 Change your window.load to document ready. It's a bit faster.