add sorting on message retries.