From ada52eee10899e68de8259c73a16b30813d1568f Mon Sep 17 00:00:00 2001 From: andreitulpan Date: Thu, 23 Feb 2023 00:30:08 +0200 Subject: [PATCH] algorithms_task_6 done --- algorithms_task_6/student/include/impl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/algorithms_task_6/student/include/impl.h b/algorithms_task_6/student/include/impl.h index 104a3cec..a81655a8 100644 --- a/algorithms_task_6/student/include/impl.h +++ b/algorithms_task_6/student/include/impl.h @@ -1,6 +1,16 @@ #pragma once #include +#include +template +void stable_sort(Container& target) { + std::stable_sort(target.begin(), target.end()); +} + +template +void stable_sort(std::list& target) { + target.sort(); +} /** * @todo insert_to_sorted @@ -18,4 +28,7 @@ void insert_to_sorted(Sequence& target, const FwIt sourceBegin, const FwIt sourc static_assert(std::is_const::reference>::type>::value, "FwIt must point to const data"); + + std::copy(sourceBegin, sourceEnd, std::back_inserter(target)); + stable_sort(target); }