#ifndef SELECTION_SORT_H
#define SELECTION_SORT_H
#include <algorithm>
template <class RandomAccessIterator>
void selection_sort(RandomAccessIterator first, RandomAccessIterator last)
{
RandomAccessIterator begin = first;
while (begin < last) {
RandomAccessIterator it, min;
bool started = false;
for (it = begin; it < last; ++it) {
if (!started || *it < *min) {
min = it;
}
started = true;
}
std::swap(*min, *begin);
++begin;
}
}
#endif // SELECTION_SORT_H