more robust date sorting