title: pandas group by project and sort within groups
body: <p>How can I output a groupby object to a csv file? 
  My original input tsv file has the following format:</p>
  
  <pre><code>id     score    domain
  1       5         x
  2       3         x
  1       4         y
  2       2         y
  </code></pre>
  
  <p>I need the output tsv file to be grouped by id and sorted by score (descending order) so it will look like this:</p>
  
  <pre><code>id      score     domain
  1        5          x
  1        4          y
  2        3          x
  2        2          y
  </code></pre>
  
  <p>Any suggestions how should I do that? I tried some groupby and sort_values functions using pandas but it did not produce the required output for me. Thanks!</p>