diff --git a/homework/length-sort/sort.cpp b/homework/length-sort/sort.cpp new file mode 100644 index 000000000..a9505c779 --- /dev/null +++ b/homework/length-sort/sort.cpp @@ -0,0 +1,11 @@ +#include "sort.hpp" +#include + +std::deque lengthSort(std::forward_list& fl) { + std::deque dq{fl.begin(), fl.end()}; + + std::sort(dq.begin(), dq.end()); + std::sort(dq.begin(), dq.end(), [](const std::string& a, const std::string& b) { return a.size() < b.size(); }); + + return dq; +} \ No newline at end of file diff --git a/homework/length-sort/sort.hpp b/homework/length-sort/sort.hpp new file mode 100644 index 000000000..4a3b8ffce --- /dev/null +++ b/homework/length-sort/sort.hpp @@ -0,0 +1,10 @@ +#ifndef SORT_HPP +#define SORT_HPP + +#include +#include +#include + +std::deque lengthSort(std::forward_list& fl); + +#endif \ No newline at end of file