[Refactoring] Reorder TemplateInstance member functions

Sort them based on the semantic order.
[Refactoring] bool TemplateInstance::hasNestedArgs(...)
Merge pull request #2573 from 9rnsr/refactor_template

[Refactoring] Reorder TemplateInstance member functions