title: Sort bar chart by list values in matplotlib
body: <p>I am encountering an issue regarding the sorting my features by their value. I would like to see my image with bars getting shorter based on how high they are on the y-axis. Unfortunately, my barplot looks like this, with the features being sorted alphabetically:</p>
  <p><a href="https://i.stack.imgur.com/nXs30.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nXs30.png" alt="enter image description here" /></a></p>
  <p>Right now I am running the following code:</p>
  <pre><code>unsorted_list = [(importance, feature) for feature, importance in 
                    zip(features, importances)]
  sorted_list = sorted(unsorted_list)
  
  features_sorted = []
  importance_sorted = []
  
  for i in sorted_list:
      features_sorted += [i[1]]
      importance_sorted += [i[0]]
   
  plt.title(&quot;Feature importance&quot;, fontsize=15)
  plt.xlabel(&quot;Importance&quot;, fontsize=13)
  
  plt.barh(features_sorted,importance_sorted, color=&quot;green&quot;, edgecolor='green')
  
  # plt.savefig('importance_barh.png', dpi=100)
  </code></pre>
  <p>Here is the data going through there:</p>
  <pre><code>unsorted_list =  
   [('HR', 0.28804817462980353),
   ('BR', 0.04062328177704225),
   ('Posture', 0.09011618483921582),
   ('Activity', 0.0017821837085763366),
   ('PeakAccel', 0.002649111136700579),
   ('HRV', 0.13598729040097057),
   ('ROGState', 0.014534726412631642),
   ('ROGTime', 0.22986192060475388),
   ('VerticalMin', 0.016099772399198357),
   ('VerticalPeak', 0.012697214182994502),
   ('LateralMin', 0.029479112475744584),
   ('LateralPeak', 0.022745210003295983),
   ('SagittalMin', 0.08653071485979484),
   ('SagittalPeak', 0.028845102569277088)]
  
  sorted_list = 
  [(0.0017821837085763366, 'Activity'),
   (0.002649111136700579, 'PeakAccel'),
   (0.012697214182994502, 'VerticalPeak'),
   (0.014534726412631642, 'ROGState'),
   (0.016099772399198357, 'VerticalMin'),
   (0.022745210003295983, 'LateralPeak'),
   (0.028845102569277088, 'SagittalPeak'),
   (0.029479112475744584, 'LateralMin'),
   (0.04062328177704225, 'BR'),
   (0.08653071485979484, 'SagittalMin'),
   (0.09011618483921582, 'Posture'),
   (0.13598729040097057, 'HRV'),
   (0.22986192060475388, 'ROGTime'),
   (0.28804817462980353, 'HR')]
  </code></pre>
  <p>I recently upgraded to matplotlib 3.0.2</p>