for i, line in enumerate(a):
    nz = np.nonzero(a[i][:])[0]
z = np.zeros(size - nz.shape[0])
a[i][:] = np.concatenate((z, a[i][:][np.nonzero(a[i][:])]))
Numpy, sort rows of a matrix putting zeros first and not modifying the rest of the row