按字符前的数字自然排序的 Unicode 列表
Natural sort of Unicode list by numbers before characters
scores2 = [u'4H', u'10H', u'18H', u'59H', u'84H', u'19A', u'38A', u'65A', u'88A', u'90A', u'']
分数 2 打印出来是这样的,
有人可以告诉我如何从列表中删除 unicode,然后仅按数字值排序,这样最后一个字母就没有排序操作了吗?我看过自然排序,但我确定这只适用于数字前的字母?
scores2 = [u'4H', u'10H', u'18H', u'59H', u'84H', u'19A', u'38A', u'65A', u'88A', u'90A', u'']
print(sorted((x.encode("utf-8") for x in scores2 if x.strip()), key=lambda x:int(x[:-1])))
['4H', '10H', '18H', '19A', '38A', '59H', '65A', '84H', '88A', '90A']
scores2 = [u'4H', u'10H', u'18H', u'59H', u'84H', u'19A', u'38A', u'65A', u'88A', u'90A', u'']
分数 2 打印出来是这样的, 有人可以告诉我如何从列表中删除 unicode,然后仅按数字值排序,这样最后一个字母就没有排序操作了吗?我看过自然排序,但我确定这只适用于数字前的字母?
scores2 = [u'4H', u'10H', u'18H', u'59H', u'84H', u'19A', u'38A', u'65A', u'88A', u'90A', u'']
print(sorted((x.encode("utf-8") for x in scores2 if x.strip()), key=lambda x:int(x[:-1])))
['4H', '10H', '18H', '19A', '38A', '59H', '65A', '84H', '88A', '90A']