title: How to sort a numpy array based on the values in a specific row?
body: <p>I was wondering how I would be able to sort a whole array by the values in one of its columns.</p>
  
  <p>I have :</p>
  
  <pre><code>array([5,2,8,2,4])
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>array([[ 0,  1,  2,  3,  4],
         [ 5,  6,  7,  8,  9],
         [10, 11, 12, 13, 14],
         [15, 16, 17, 18, 19],
         [20, 21, 22, 23, 24]])
  </code></pre>
  
  <p>I want to append the first array to the second one like this:</p>
  
  <pre><code>array([[ 0,  1,  2,  3,  4],
         [ 5,  6,  7,  8,  9],
         [10, 11, 12, 13, 14],
         [15, 16, 17, 18, 19],
         [20, 21, 22, 23, 24],
         [5,  2,  8,  2,  4]])
  </code></pre>
  
  <p>And then sort the array by the appended row to get either this:</p>
  
  <pre><code>array([[1,  3,  4,  0,  2],
         [6,  8,  9,  5,  7],
         [11, 13, 14, 10, 12],
         [16, 18, 19, 15, 17],
         [21, 23, 24, 20, 22],
         [2,  2,  4,  5,  8]])
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>array([[ 2,  1,  3,  4,  0],
         [ 7,  6,  8,  9,  5],
         [12, 11, 13, 14, 10],
         [17, 16, 18, 19, 15],
         [22, 21, 23, 24, 20],
         [ 8,  5,  4,  2,  2]])
  </code></pre>
  
  <p>And then remove the appended column to get:</p>
  
  <pre><code>array([[1,  3,  4,  0,  2],
         [6,  8,  9,  5,  7],
         [11, 13, 14, 10, 12],
         [16, 18, 19, 15, 17],
         [21, 23, 24, 20, 22]])
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>array([[ 2,  1,  3,  4,  0],
         [ 7,  6,  8,  9,  5],
         [12, 11, 13, 14, 10],
         [17, 16, 18, 19, 15],
         [22, 21, 23, 24, 20]])
  </code></pre>
  
  <p>Is there a code to carry out this procedure. I am very new to python. Thanks a lot!</p>