Make sure dates are sorted.