Sort query by timestamp.