from itertools import groupby
from operator import itemgetter
grouped = [(uniq, len(list(dups))) for uniq, dups in groupby(sorted(list1))]
How to sort a list with duplicate items by the biggest number of duplicate occurrences - Python