title: Sorting numpy matrix for a given column
body: <p>I've tried to use Ned Batchelder code to sort in human order a <code>NumPy</code> matrix, as it was proposed in this following post:</p>
  
  <p><a href="https://stackoverflow.com/q/7638738">Sort numpy string array with negative numbers?</a></p>
  
  <p>The code runs on a one-dimensional array, the command being:</p>
  
  <pre><code>print (sorted(a, key=natural_keys))
  </code></pre>
  
  <p>Now, my problem is that my data is a 10 column matrix and I want to sort it according to one column (let's say <code>MyColumn</code>). I can't find a way to modify the code to print the whole matrix sorted according to this very column. All I could come up with is this:</p>
  
  <pre><code>print (sorted(a['MyColumn'], key=natural_keys))
  </code></pre>
  
  <p>But, of course, only <code>MyColumn</code> shows up in the output, although it is correctly sorted...</p>
  
  <p><strong>Is there a way to print the whole Matrix?</strong></p>
  
  <p>Here is the command I used to load my array (I simplified my original imputfile to a 3 column array):</p>
  
  <pre><code>data = np.loadtxt(inputfile, dtype={'names': ('ID', 'MyColumn', 'length'),
  'formats': ('int32', 'S40', 'int32')},skiprows=1, delimiter='\t')
  
  ID  MyColumn    length
  164967  BFT_job13_q1_type2  426
  197388  BFT_job8_q0_type2   244
  164967  BFT_job13_q0_type1  944
  72406   BFT_job1_q0_type3   696
  </code></pre>
  
  <p>Here is what the output would ideally look like:</p>
  
  <pre><code>ID  MyColumn    length
  72406   BFT_job1_q0_type3   696
  197388  BFT_job8_q0_type2   244
  164967  BFT_job13_q0_type1  944
  164967  BFT_job13_q1_type2  426
  </code></pre>