diff --git a/labs/core_bound/function_inlining_1/solution.cpp b/labs/core_bound/function_inlining_1/solution.cpp index 4c8af264..3dc186a9 100644 --- a/labs/core_bound/function_inlining_1/solution.cpp +++ b/labs/core_bound/function_inlining_1/solution.cpp @@ -3,25 +3,6 @@ #include #include -static int compare(const void *lhs, const void *rhs) { - auto &a = *reinterpret_cast(lhs); - auto &b = *reinterpret_cast(rhs); - - if (a.key1 < b.key1) - return -1; - - if (a.key1 > b.key1) - return 1; - - if (a.key2 < b.key2) - return -1; - - if (a.key2 > b.key2) - return 1; - - return 0; -} - void solution(std::array &arr) { - qsort(arr.data(), arr.size(), sizeof(S), compare); + std::sort(arr.begin(), arr.end()); } diff --git a/labs/core_bound/function_inlining_1/solution.h b/labs/core_bound/function_inlining_1/solution.h index 99f212d1..05355837 100644 --- a/labs/core_bound/function_inlining_1/solution.h +++ b/labs/core_bound/function_inlining_1/solution.h @@ -9,6 +9,22 @@ constexpr size_t N = 10000; struct S { uint32_t key1; uint32_t key2; + + bool operator<(const S &other) const { + if (key1 < other.key1) { + return true; + } + if (key1 > other.key1) { + return false; + } + if (key2 < other.key2) { + return true; + } + if (key2 > other.key2) { + return false; + } + } + }; void init(std::array &arr);