correct sort by date logic.