fixing error when sorting date column