Wrong application of np.sort()
Wrong use of references and copies
in trapz: y first, then x
y_new has to be an different array, but same shape
This looks definetly better