How to arrange array in decreasing order of frequency of each number?
- by Rajendra
Input : {5, 13, 6, 5, 13, 7, 8, 6, 5}
Output : {5, 5, 5, 13, 13, 6, 6, 7, 8}
Question is to arrange the numbers in the array in decreasing order of their frequency preserving the order of their occurrence.
If their is a tie, for example, here 13 and 6 then the number occurring first in input array would come first in output array.