I have an array which contains duplicate values. I want to sort the array so that the values with the most duplicates appear first in line. Here's an example of my array:
array(1, 2, 3, 2, 1, 2, 2);
I want to sort this array so that it orders itself based on the amount of duplicates into the following:
array(2, 1, 3);
'2' has the most duplicates so it's sorted first, followed by values will less duplicates. Does anyone know how I can accomplish this?