title: How to sort pivot table in Pandas
body: <p>Here is the code:</p>
  
  <pre><code>test = pd.DataFrame({'country':['us','ca','ru','cn','ru','cn','us','ca','ru','cn','us','ca','ru','cn','us','ca'], 'month':[5,6,7,5,6,7,5,5,6,7,5,6,6,5,5,6], 'id':[x for x in range(16)]})
  p = test.pivot_table(index=['month', 'country'], aggfunc='count')[['id']]
  </code></pre>
  
  <p>The output looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/7h3qh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7h3qh.png" alt="enter image description here"></a></p>
  
  <p>I'd like to sort the table by the <code>id</code> column, so that the largest number appear on top like:</p>
  
  <pre><code>                    id
  month    country
             us       4
    5        cn       2
             ca       1
  </code></pre>