ATL sorting templates

Active Template Library (ATL) contains a lot of useful classes but not for sorting. There are collections classes, including CAtlArray but it does not have sorting capabilities.

I would like to share quite simple C++ templates that sort.

The sample projects illustrates 3 sorting cases:

  1. Array of ordinal values that compare one to another; sorting uses comparison operator to order values.
  2. Array of complex values that do not compare one to another directly and a custom comparison function is required; sorting uses “traits” class to perform such comparison.
  3. Array of references (indexes, pointers); “traits” class is provided to sort function along with custom parameter which is also passed to comparison function.

Sample project source code: ATL Sort.zip // VC++.NET 2003, Console application project with ATL support

One Reply to “ATL sorting templates”

Leave a Reply