title: Sort by column within multi index level in pandas
body: <p>I have a sorting request per example below.</p>
  
  <p>Do i need to reset_index(), then sort() and then set_index() or is there a slick way to do this?</p>
  
  <pre><code>l = [[1,'A',99],[1,'B',102],[1,'C',105],[1,'D',97],[2,'A',19],[2,'B',14],[2,'C',10],[2,'D',17]]
  df = pd.DataFrame(l,columns = ['idx1','idx2','col1'])
  df.set_index(['idx1','idx2'],inplace=True)
  
  # assume data has been received like this...
  print df
  
             col1
  idx1 idx2      
  1    A       99
       B      102
       C      105
       D       97
  2    A       19
       B       14
       C       10
       D       17
  
  # I'd like to sort descending on col1, partitioning within index level = 'idx2'
  
             col1
  idx1 idx2      
  1    C      105
       B      102
       A       99
       D       97
  
  2    A       19
       D       17
       B       14
       C       10
  </code></pre>
  
  <hr>
  
  <p>Thank you for the answer
  Note I change the data slightly:</p>
  
  <pre><code>l = [[1,'A',99],[1,'B',11],[1,'C',105],[1,'D',97],[2,'A',19],[2,'B',14],[2,'C',10],[2,'D',17]]
  df = pd.DataFrame(l,columns = ['idx1','idx2','col1'])
  df.set_index(['idx1','idx2'],inplace=True)
  df = df.sort_index(by='col1', ascending=False)
  </code></pre>
  
  <p>however the output is </p>
  
  <pre><code>idx1 idx2      
  1    C      105
       A       99
       D       97
  2    A       19
       D       17
       B       14
  1    B       11
  2    C       10
  </code></pre>
  
  <p>i would have wanted it to be </p>
  
  <pre><code>idx1 idx2      
  1    C      105
       A       99
       D       97
       B       11
  
  2    A       19
       D       17
       B       14
       C       10
  </code></pre>