Let's say I have a list like so:
list = [0,0,1,1,1,1,1,1,1,1,3,3,3,3,5,9,9,9,9,9,9,22,22,22,22,22,22,22,22,22,22,45]
The top 5 reoccurring values would be: 22, 1, 9, 3, and 0.
What is the best way to get these values, as well as the number of times they reoccur? I was thinking of pushing the values into a new list, so that I get something like:
new_list = [22,10, 1,8, 9,6, 3,4, 0,2]
With the list value being the odd index entry, and the reoccurred value being the even index entry.
EDIT: What is the simplest way to do this without using a library?