I am looking for a concise JavaScript function which takes some values and returns the unique values sorted by the number of occurrences, the most frequent first.
For example, if the input is the array [3,2,2,2,2,1,2,1] then the output should be [2,1,3].
{}) and arrays ([]), and I'm not sure how you'd apply this to objects.