The sort function takes a function, and thus your template has to be instantiated at the point it is passed to the sort function.
Ah! Thanks a lot - that's what I was missing! sort is expecting a function and I provide a template... even though it will call the function multiple times later and would be able to figure out what to do with a template it still expects a function as an argument. Thanks a lot about this, I figured it out thanks to this comment. Though I wouldn't say it will be illogical if they added an overload of sort() where it can take a function template, or would it?