Initial TemplateSort code
WIP
(*) Major cleanup. The code is now good, however we still need to work on the tests.
(*) Finished implementing TemplateSort as well as all unit tests.
Merge branch 'TemplateSort'