range with templated sort functions