title: Pig: Get top n values per group
body: <p>I have data that's already grouped and aggregated, it looks like so:</p>
  
  <pre><code>user    value      count
  ----    --------  ------
  Alice   third      5
  Alice   first      11
  Alice   second     10
  Alice   fourth     2
  ...
  Bob     second     20
  Bob     third      18
  Bob     first      21
  Bob     fourth     8
  ...
  </code></pre>
  
  <p>For every user (Alice and Bob), I want retrieve their <strong>top n values</strong> (let's say 2), sorted terms of 'count'.
  So the desired output I want is this:</p>
  
  <pre><code>Alice first 11
  Alice second 10
  Bob first 21
  Bob second 20
  </code></pre>
  
  <p>How can I accomplish that?</p>