title: numpy python raising non zero values to top of 2d array quickly and efficiently
body: <p>Sorry about the title, I would be looking for a suggestion if someone has a better description.  I want a function (that is as quick as possible) that gets the non-zero entries and populates a new array with the ordered version of the previous array.  It probably is clearer from the example below:</p>
  
  <p><strong>Input Array</strong></p>
  
  <pre><code>np.random.seed(2)
  a = np.random.randint(0,10,10)
  b = np.random.randint(0,10,10)
  c = np.random.randint(0,10,10)
  a = 0 * (a % 2) + (1-(a % 2))*a
  b = 0 * (b % 2) + (1-(b % 2))*b
  c = 0 * (c % 2) + (1-(c % 2))*c
  arr = np.array([a,b,c])
  
  arr
  &gt;&gt;&gt; array([[8, 8, 6, 2, 8, 0, 2, 0, 0, 4],
             [4, 0, 0, 0, 6, 4, 0, 0, 6, 0],
             [0, 0, 8, 4, 6, 0, 0, 2, 0, 4]])
  </code></pre>
  
  <p><strong>Output Array</strong></p>
  
  <pre><code>outArr = np.empty_like(arr)
  outArr[0,:] = (arr[0,:] &gt; 0) * arr[0,:] + ~(arr[0,:] &gt; 0) * (arr[1,:] &gt; 0) * arr[1,:] + ~(arr[0,:] &gt; 0) * ~(arr[1,:] &gt; 0) * arr[2,:]
  outArr[1,:] = (arr[0,:] &gt; 0) * arr[1,:] + (arr[0,:] &gt; 0) * ~(arr[1,:] &gt; 0) * arr[2,:]
  outArr[2,:] = (arr[0,:] &gt; 0) * (arr[1,:] &gt; 0) * arr[2,:]
  
  outArr
  &gt;&gt;&gt; array([[8, 8, 6, 2, 8, 4, 2, 2, 6, 4],
             [4, 0, 8, 4, 6, 0, 0, 0, 0, 4],
             [0, 0, 0, 0, 6, 0, 0, 0, 0, 0]])
  </code></pre>
  
  <p>Where I have hard coded this array to be 3 rows only so I can hand type the function, in reality this could be more rows (on the order of tens nothing too crazy).</p>
  
  <p><em>EDIT:</em></p>
  
  <p>The dimensions that I would actually like to use are 5ish rows by 100-150k columns</p>
  
  <p>The data type will always be integers</p>
  
  <p>Finally, the update process is I add a new row at the bottom, justify upwards, and then remove all trailing rows of only 0s (null values)</p>