Counting the number of repeating values in a list

I have a list of repeating values from 0 to 1500. The total length of the list is 80.000. Each value repeats differently. I would like to create a list with the number of times each value is found in a list.
I found THIS solution which separates same values into branches. I could use list length to get the number of repeats, but this solution tests every number for equality and it’s not very efficient. Is there a better way?

So the list looks something like:

0
1
1
2
2
2
2
2
3
3

and I would like to get:

1
2
5
2

Until some other good Samaritan does it with components … get this:

Lists_LINQ_CountSame_V1.gh (12.4 KB)

Thank you, but it doesn’t seem to work. I entered my list in the userList and there is no output.
In the demo, it seems that the count is also sorted from highest to lowest, which is not what I want.

2 Likes

Well … that was … er … hmm … a wrong if clause (I hate mistakes even the smallest one). Added Order option(s).

Lists_LINQ_CountSame_V1A.gh (9.8 KB)