improve sorting logic and change the redirect link