title: How to sort two-dimensional array by first column as numeric when list of strings? (Python)
body: <p>I have a two-dimensional array that I'm trying to sort by the first column. However, currently every element in the array is a string, and I'd like the first column to be treated as an integer so I can sort numerically (1, 2, 6, 11... instead of 1, 11, 224, 23,...). I'm using the numpy package to generate these arrays using <code>x = numpy.loadtxt('file.txt', dtype = 'str', delimiter = '\t')</code> which gives me:</p>
  
  <pre><code>array([['140', 'GGC'],
         ['256', 'AGGG'],
         ['841', 'CA'],
         ['46', 'TTATAGG'],
         ['64', 'AGAGAAAGGATTATG'],
         ['156', 'AGC'],
         ['187', 'GGA'],
         ['701', 'TTCG'],
         ['700', 'TC']], 
        dtype='|S15')
  </code></pre>
  
  <p>1) I know I can convert the first column to integers using:</p>
  
  <pre><code>x[:,0].astype(int)
  </code></pre>
  
  <p>which outputs a 1-D array. But I'm not sure how to make changes directly to my 2-D array?</p>
  
  <p>2) Once I can convert (or treat) my first column to integers, I know I can sort using:</p>
  
  <pre><code>sorted(x, key=lambda x: x[0])
  </code></pre>
  
  <p>But is this the best way to do so for my data type?</p>