changed *x.sort()*(for lists) to *np.sort(x)* (for numpy arrays)
the two lists were identified with each other and changes applied to both. Made a real copy by changing *new_list = list* to *new_list = deepcopy(list)*
the command *trapz* takes the function to integrate over as first argument and the axis to integrate along as second argument. They were reversed in the code, fixed that
the array *y_new* and *y* were identified with each other; changes applied to both. Fixed by setting *y_new = y* to *y_new = y.copy()*