Collection of sorting types A collection of sorting types as following insertion, radix, selection and heap sorts.

How can i improve it?

#include &lt;algorithm&gt;
#include &lt;functional&gt;
#include &lt;type_traits&gt;
#include &lt;iostream&gt;


template &lt;typename Iterator&gt;
void radixSort(Iterator begin, Iterator end)
{
    using value_type = typename std::iterator_traits&lt;Iterator&gt;::value_type;

    for (auto i = 0; i &lt; 32; ++i)
    {
        std::stable_partition(begin, end,
            [&amp;](value_type&amp; value)
        {
            if (i == 31) 
                return value &lt; 0; 
            else
                return !(value &amp; (1 &lt;&lt; i));
        });
    }
}

template&lt;typename Iterator&gt;
void insertionSort(Iterator begin, Iterator end)
{
    using value_type = typename std::iterator_traits&lt;Iterator&gt;::value_type;

    for (auto i = begin; i != end; ++i)
    {
        std::rotate(std::upper_bound(begin, i, *i, std::less&lt;value_type&gt;()), i, std::next(i));
    }
}

template &lt;typename Iterator&gt;
void selectionSort(Iterator begin, Iterator end)
{
    using value_type = typename std::iterator_traits&lt;Iterator&gt;::value_type;

    for (; begin != end; ++begin)
    {
        const auto minElemt(std::min_element(begin, end, std::less&lt;value_type&gt;()));

        if (begin != minElemt)
        {
            std::iter_swap(begin, minElemt);
        }
    }
}

template &lt;typename Iterator&gt;
void heapSort(Iterator begin, Iterator end)
{
    using value_type = typename std::iterator_traits&lt;Iterator&gt;::value_type;

    std::make_heap(begin, end, std::less&lt;value_type&gt;());
    std::sort_heap(begin, end, std::less&lt;value_type&gt;());
}

int main()
{
    int a[] = {9,-6, 7, -8, 6, -9, 1, 3, -4, 2, -1, -5, 5, 8, -3, 4, 0, -2, -7 };

    radixSort(std::begin(a), std::end(a));
    //insertionSort(std::begin(a), std::end(a));
    //selectionSort(std::begin(a), std::end(a));
    //heapSort(std::begin(a), std::end(a));

    for (const auto&amp; i : a)
    {
        std::cout &lt;&lt; i &lt;&lt; ' ';
    }
}
In radixSort you assume that std::iterator_traits&lt;Iterator&gt;::value_type is a signed 32bit int.

Instead you should check whether it's an integral type and alter the algorithm a bit based on its properties:

template &lt;typename Iterator&gt;
void radixSort(Iterator begin, Iterator end)
{
    using value_type = typename std::iterator_traits&lt;Iterator&gt;::value_type;

    static_assert(std::numeric_limits&lt;value_type&gt;::is_integer, "Wrong type");

    for (auto i = 0; i &lt; std::numeric_limits&lt;value_type&gt;::digits; ++i)
    {
        std::stable_partition(begin, end,
            [&amp;](value_type&amp; value)
        {
             return !(value &amp; (1 &lt;&lt; i));
        });
    }

    if(std::numeric_limits&lt;value_type&gt;::is_signed){
        std::stable_partition(begin, end,
            [&amp;](value_type&amp; value)
        {
             return value &lt; 0;
        });
    }

}


Besides that all your algorithms use the standard std::less comparator. you should let the user supply a comparator (a mapping function for radixSort) for types that don't have a default std::less.