handle sort options after getting the template