Fixed problems:
ex1: added line x.sort() and then return x
ex2: new_values was a pointer to values
ex3: arguments in trapz() were in the wrong order
ex4: same as ex2.