inline void _insertion_sort_recursive(ContainerT &container, size_t p, size_t q) noexcept { if (p > 0) { _insertion_sort_recursive(container, p - 1, q); auto key = container.at(p); int j; for (j = static_cast<int>(p - 1); j >= 0 && container.at(j) > key; --j) { container.at(j + 1) = container.at(j); } container.at(j + 1) = key; } }
inline void selection_sort(ContainerT &container) noexcept { const size_t containerSize = container.size(); for (size_t i = 0; i < containerSize - 1; ++i) { size_t elemIndex = i; for (int j = i; j < containerSize; ++j) { if (container.at(elemIndex) > container.at(j)) { elemIndex = j; } } algorithm::swap(container.at(i), container.at(elemIndex)); } }