from collections import Counterc = Counter(data)b = sorted(c.most_common(), key=lambda x: (-x[1], x[0]))print(b)