I'm trying to sort an array in a special way.
I want to sort an array so the elements that appear most freqently are placed at the beginning of the array.
Here's my array:
$myArray =
("75|FILES",
"75|FILES",
"59|FILES",
"1|FILES",
"75|ARTICLES",
"98|CONFERENCES",
"194|SPEAKER_BIOS",
"75|FILES",
"75|FILES",
"44|FILES",
"98|CONFERENCES");
As you can see, I have 5 occurrences of "75|FILES" and 2 occurrences of "98|CONFERENCES".
I want to place the "75|FILES" at the beginning of the array, followed by "98|CONFERENCES", then the rest of the array elements that appear only once.
WANT THIS END RESULT:
$myArray =
("75|FILES",
"75|FILES",
"75|FILES",
"75|FILES",
"75|ARTICLES",
"98|CONFERENCES",
"98|CONFERENCES",
"59|FILES",
"1|FILES",
"194|SPEAKER_BIOS",
"44|FILES");
ANY IDEAS?