fn = sorted(finalDataSet,key = lambda x : x[1],reverse=True)
我得到了这样的结果:
[('Hyperelastic', '8%'), ('Orthotropic', '26%'), ('Plastic', '23%'),
('Composites', '17%'), ('Anisotropic', '13%'), ('Thermal', '13%')]
答案 0 :(得分:0)
它似乎工作正常。您按字符串排序,按字母顺序排序' 8%'被认为大于26%'您可能会发现这更有用lambda
:
lambda x : float(x[1].strip('%'))