mirror of
https://gitlab.com/niansa/frigg.git
synced 2025-03-06 20:53:32 +01:00
21 lines
311 B
C++
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
|