example1: use np.sort() instead of x.sort(), example2: deepcopy required, example 3: switch x and y in trapz, example4: another deepcopy required