title: Python balancing items in a list/numpy array
body: <p>I have an array of tokens, and each token corresponds to a different class from <code>1</code> to <code>n</code>. I need to <em>balance</em> the <code>tokens</code> array/list so that there are an equal number of tokens for each class. I want to do this by removing the elements of <code>tokens</code>.</p>
  
  <p>In the example below the class with the lowest number of tokens is <code>class 2</code>  which has only <code>2</code> tokens. So I want to remove elements from other classes until their count is also <code>2</code>.</p>
  
  <p>e.g.</p>
  
  <pre><code>tokens  = array(['a','b','c','d','e','f','g','h','l'])
  
  classes = array([ 1 , 1 , 1 , 1 , 2 , 2 , 3 , 3 , 3])
  </code></pre>
  
  <p>In this example, the classes are listed in ascending order (for clarity of task) but in reality, the classes are in no particular order.</p>
  
  <p>e.g.</p>
  
  <pre><code>sol = array(['c','d','e','f','g','h'])
  </code></pre>
  
  <p><em>or</em></p>
  
  <pre><code>sol = array(['a','b','e','f','g','h'])
  </code></pre>
  
  <p><em>etc.</em></p>
  
  <p>Obviously because you have a choice of elements to remove in an excess class, you can have different solutions (like above). I need a function that can take the <code>tokens</code> and <code>classes</code> and output a <code>sol</code>.</p>