Suppose I have an array with n elements, some of which may occur more than once.
I want to select the top m elements that occur most often in that array.
Can anybody help me with that?
For example, suppose the array is [1, 3, 2, 3, 5, 2, 2, 3, 6, 8, 9] with n=11 elements. If I want to select the top m=2 of them, those would be 2 and 3.
What would be the best script to do that?
{ value: n, count: c }objects. Sort them bycount. Then take the firstmelements.