How to arrange array in decreasing order of frequency of each number?
Posted
by Rajendra
on Stack Overflow
See other posts from Stack Overflow
or by Rajendra
Published on 2010-03-25T16:07:50Z
Indexed on
2010/03/25
16:13 UTC
Read the original article
Hit count: 276
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.
© Stack Overflow or respective owner