C++ (templated) implementation of sorting algorithms