sort() is a numpy function that needs the array to be sorted as argument, it's not a method of the numpy-array type itself. So the returned value was changed to np.sort(x)
new_values=values is just a reference, we need to do a true copy with deepcopy
wrong order of arguments: trapz needs the y array first, so x and y swapped
y_new is just a reference, so during the method we filter partially already filtered values. This problem can be solved by doing a true copy in the median_filter method.