title: Special sorting pivot table Pandas
body: <p>I am having difficulties trying to sort my pandas pivot table. </p>
  
  <p>So, I am parsing a dataset in HTML on the web and wrangles it to fit it in a DataFrame.</p>
  
  <p>What I have now looks like this:</p>
  
  <pre><code>    df = pd.DataFrame(rows, columns=['Customer', 'Paper', 'Exch', 'Quantity', 'Max sell', 'Value', 'Borrowed'])
  df = df.drop(df.columns[[2,4,6]], axis=1)
  df = df.drop(df.index[0])
  df[['Value', 'Quantity']] = df[['Value', 'Quantity']].convert_objects(convert_numeric=True)
  df = df.clip(lower=0)
  df = df[df.Paper != '*Cash']
  df = df.dropna()
  
  
  df = pd.pivot_table(df, values=['Value', 'Quantity'], index=['Paper', 'Customer'], aggfunc=sum)
  
  
  print df.to_string()
  </code></pre>
  
  <p>And it outputs this:</p>
  
  <p><a href="https://i.stack.imgur.com/DuQF4.png" rel="nofollow noreferrer">Output</a></p>
  
  <p>It is sorting alphabetically on 'Stock and then 'Customer'. I want it to sort on 'Value' but in the same pivot format like it outputs now. </p>
  
  <p>This is what I want:</p>
  
  <p><a href="https://i.stack.imgur.com/9iVUH.png" rel="nofollow noreferrer">What I want</a></p>
  
  <p>Bonus: How can I add another column with percent of total and display all of this in a simple bar chart?</p>
  
  <p>I would be so happy if someone can help with this. Thank you!</p>
  
  <p>EDIT: Forgot to paste the pd.pivot_table code. Now in place.</p>