Given a list of integers, group the elements which occur most first, then group the next most and so on until each unique element in the list has been grouped once.
Examples:
Input: [1,2,3]
Output: [[1,2,3]]
Input: [1,1,1,2,2,3,3,4,5,6]
Output: [[1],[2,3],[4,5,6]]
Input: [1,1,1,4,5,6,6,6,7,7,8,8,8,8,8,8,8,9,5,6,5,6,5,6,5,6,-56]
Output: [[6, 8],[5],[1],[7],[9,4,-56]]
Input: []
Output: []
Input: (empty input)
Output: ERROR/Undefined/Doesn't matter
Rules
- Groupings must go from maximal frequency to minimal frequency.
- Internal order of the groupings are arbitrary (E.G. example 3 could have
[8,6]
instead). - This is code-golf, lowest byte-count wins.