title: Pandas sort by group aggregate and column
body: <p>Given the following dataframe</p>
  
  <pre><code>In [31]: rand = np.random.RandomState(1)
           df = pd.DataFrame({'A': ['foo', 'bar', 'baz'] * 2,
                              'B': rand.randn(6),
                              'C': rand.rand(6) &gt; .5})
  
  In [32]: df
  Out[32]:      A         B      C
           0  foo  1.624345  False
           1  bar -0.611756   True
           2  baz -0.528172  False
           3  foo -1.072969   True
           4  bar  0.865408  False
           5  baz -2.301539   True 
  </code></pre>
  
  <p>I would like to sort it in groups (<code>A</code>) by the aggregated sum of <code>B</code>, and then by the value in <code>C</code> (not aggregated). So basically get the order of the <code>A</code> groups with</p>
  
  <pre><code>In [28]: df.groupby('A').sum().sort('B')
  Out[28]:             B  C
           A               
           baz -2.829710  1
           bar  0.253651  1
           foo  0.551377  1
  </code></pre>
  
  <p>And then by True/False, so that it ultimately looks like this:</p>
  
  <pre><code>In [30]: df.ix[[5, 2, 1, 4, 3, 0]]
  Out[30]: A         B      C
      5  baz -2.301539   True
      2  baz -0.528172  False
      1  bar -0.611756   True
      4  bar  0.865408  False
      3  foo -1.072969   True
      0  foo  1.624345  False
  </code></pre>
  
  <p>How can this be done?                         </p>