title: How to sort bars in a bar plot in ascending order
body: <p>I created a bar plot using <code>matplotlib.pyplot</code> and seaborn libraries. How can I sort bars in increasing order according to <code>Speed</code>? I want to see the bars with the lowest speed on the left and the highest speed on the right.</p>
  <pre><code>df =
      Id         Speed
      1          30
      1          35 
      1          31
      2          20
      2          25
      3          80
  
  import pandas as pd
  import matplotlib.pyplot as plt
  import seaborn as sns
  
  %matplotlib inline
  
  result = df.groupby([&quot;Id&quot;])['Speed'].aggregate(np.median).reset_index()
  
  norm = plt.Normalize(df[&quot;Speed&quot;].values.min(), df[&quot;Speed&quot;].values.max())
  colors = plt.cm.Reds(norm(df[&quot;Speed&quot;])) 
  
  plt.figure(figsize=(12,8))
  sns.barplot(x=&quot;Id&quot;, y=&quot;Speed&quot;, data=gr_vel_1, palette=colors)
  plt.ylabel('Speed', fontsize=12)
  plt.xlabel('Id', fontsize=12)
  plt.xticks(rotation='vertical')
  plt.show()
  </code></pre>