ranks = [‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘T’, ‘J’, ‘Q’, ‘K’, ‘A’]
ranks_value = {‘2’: 2, ‘3’: 3, ‘4’: 4, ‘5’: 5, ‘6’: 6, ‘7’: 7, ‘8’: 8, ‘9’: 9, ‘T’: 10, ‘J’: 11, ‘Q’: 12, ‘K’: 13,
‘A’: 14}
要排序的:r
r = [‘5’, ‘2’, ‘7’, ‘8’, ‘3’, ‘Q’, ‘K’, ‘4’, ‘6’, ‘9’, ‘T’, ‘J’, ‘A’]
new = sorted(r,key=lambda x:ranks_value[x])
print(new)
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
ranks_value = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13,
'A': 14}
r = ['5', '2', '7', '8', '3', 'Q', 'K', '4', '6', '9', 'T', 'J', 'A']
new = sorted(r, key=lambda x: ranks_value[x])
print(new)