Fix bug in correlation_length(). sort() sorts complex values by the real part (and then the imaginary part), so avoid this by working soley with the magnitudes.