resolve bug in date sorting