title: Numpy: sort by key function
body: <p>Is there a way to sort the rows of a numpy ndarray using a key (or comparator) function, without resorting to converting to a python list? </p>
  
  <p>In particular, I need to sort according to this function:</p>
  
  <pre><code>c1,c2= 4,7
  lambda row: c1*(row[1]/c2)+row[0]
  </code></pre>
  
  <p>I realise one possible solution would be to generate a vector with the key value of each row, but how would one sort according to it? Should one seek to convert such vector into a index vector somehow?</p>
  
  <pre><code>order= c1*(matrix[:,1]/c2)+matrix[:,0]
  indexes= order_to_index( order )
  return matrix[ indexes ]
  </code></pre>
  
  <p>Is this realistic?</p>