Sort templates before returning