fork download
  1. import numpy as np
  2.  
  3. a = np.array([9, 0, 3, 8, 1, 0, 0, 0])
  4.  
  5. def key(a):
  6. return a != 0
  7.  
  8.  
  9. print(a[np.argsort(key(a))])
  10.  
Success #stdin #stdout 0.2s 27216KB
stdin
Standard input is empty
stdout
[0 0 0 0 9 3 8 1]