I would like to implement the following code:
a = [1, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5]
sorted(a,key=a.count,reverse=True)
>>> [5, 5, 5, 5, 3, 3, 3, 4, 4, 4, 1, 1, 2]
For the case when a is a np.array
a = np.array([1, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5])
How to do it? np.array has np.unique() function that calculate occurence of each element, but I don't see how can I utilize it here.