[3, 3, 3, 4, 4, 2]
Would be:
[ (3, 3), (4, 2), (2, 1) ]
The output should be sorted by highest count first to lowest count. In this case, 3 to 2 to 1.
data = [3, 3, 3, 4, 4, 2]
result = []
for entry in set(data):
result.append((entry, data.count(entry)))
result.sort(key = lambda x: -x[1])
print result
>>[(3, 3), (4, 2), (2, 1)]