fork download
  1. a = [['3D'], ['3D', '4D', '5D'], ['4C'], ['4C', '4D'], ['4D'], ['5D'], ['JC'], ['JC', 'JS'], ['JS']]
  2. confrom = {'3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, '0':10, 'J':11, 'Q':12, 'K':13, 'A':14, '2':15}
  3. print sorted(a, key = lambda x: (len(x), [confrom[card[0]] for card in x]))
Success #stdin #stdout 0.02s 4676KB
stdin
Standard input is empty
stdout
[['3D'], ['4C'], ['4D'], ['5D'], ['JC'], ['JS'], ['4C', '4D'], ['JC', 'JS'], ['3D', '4D', '5D']]