Sort works as a template function, with tests and documentation