Group by and count
Your task
Implement SELECT value, COUNT(*) FROM t GROUP BY value plus a DISTINCT count. Given a list of integer values, return a pair [distinct_count, pairs] where distinct_count is the number of distinct values and pairs is a list of [value, count] for each distinct value, sorted by value ascending. Preserve exact occurrence counts. The input may be empty. Up to 100000 values.
Examples
distinct_with_count(values: list[int]) -> listExample 1
Input
distinct_with_count([3, 1, 3, 2, 1, 3])Output
[3, [[1, 2], [2, 1], [3, 3]]]