1
0
Fork 0
mirror of https://gitlab.com/niansa/frigg.git synced 2025-03-06 20:53:32 +01:00
frigg/include/frg/algorithm.hpp
2021-03-23 21:45:32 +01:00

21 lines
311 B
C++

#pragma once
#include <utility>
namespace frg {
template <typename Iter, typename Comp>
void insertion_sort(Iter begin, Iter end, Comp comp) {
for (auto i = begin; i < end; ++i) {
auto j = i;
++j;
for (; j < end; ++j) {
if (comp(*i, *j)) {
std::swap(*i, *j);
}
}
}
}
} // namespace frg