Sorts the template keys before rendering