fork download
  1. S1 = [5, 9, 11, 10, 2, 5, 5]
  2. counter = [0] * 14
  3.  
  4. for i in S1:
  5. counter[i] = counter[i] + 1
  6.  
  7. S1.sort(key=lambda x: (-counter[x], -x))
  8.  
  9. print(S1)
Success #stdin #stdout 0.03s 9552KB
stdin
Standard input is empty
stdout
[5, 5, 5, 11, 10, 9, 2]