Group by and count in List
<p>I have an List which is filled with ints, like this:</p>

<pre><code>[0] 1
[1] 4
[2] 4
[3] 8
[4] 9
[5] 1
[6] 1
</code></pre>

<p>So basically random numbers in there, but the same number can occure multiple times in that list.</p>

<p>What i want is to group them by number, but that i can also tell how many times that number was in the list. So that i have a something like:</p>

<pre><code>[0] 
  [number] 1
  [total] 3  // Occured 3 times in the list
[1]
  [number] 4
  [total] 2
[2]
  [number] 8
  [total] 1
[3]
  [number] 9
  [total] 1
</code></pre>

<p>Is there a fast/easy way to accomplish this? Or do i have the write out all sorts of loops and checks to construct something like this manually?</p>
