import numpy as nplst = [1, -2, 10, -12, -4, -5, 9, 2]ar = np.array(lst)lst = list(np.concatenate([np.sort(ar[ar >= 0]), np.sort(ar[ar < 0], reverse = True)], axis = 0))print(lst)
And if you don't have to use a list but are happy with numpy arrays then you don't have to pay the costs of casting, i.e.
import numpy as npar = np.array([1, -2, 10, -12, -4, -5, 9, 2])ar = np.concatenate([np.sort(ar[ar >= 0]), np.sort(ar[ar < 0])], axis = 0)print(ar)