I have an array that sometimes has duplicate entries, say I have an array
array("dog", "cat", "cat", "mouse", "cat", "dog")
Now if I used the method I found here I can make the array a unique array like this
array("dog", "cat", "mouse")
However what I am trying to do is sort this list based on value density first, so for example there are 3 cats, 2 dogs and 1 mouse in the original array, but with unique this order is not correct dog->cat->mouse instead of cat->dog->mouse. How could I sort an array by density and then make it unique?