From c46358389191e25d6317ec594a6af76b97a8eb81 Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Sun, 14 May 2023 22:28:20 +0300 Subject: [PATCH] Moving into ArrayElement --- src/sfall_arrays.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sfall_arrays.cc b/src/sfall_arrays.cc index 8d72371..f135130 100644 --- a/src/sfall_arrays.cc +++ b/src/sfall_arrays.cc @@ -389,9 +389,13 @@ void SFallArrayAssoc::MapSort(int type) if (sortByValue) { ListSort(keys, type, [this](const ArrayElement& a, const ArrayElement& b) -> bool { - auto& aEl = this->map[a]; - auto& bEl = this->map[b]; - return aEl < bEl; + // Why return this->map[a] < this->map[b] does not work? Why it requires copy constructor? + auto itA = this->map.find(a); + auto itB = this->map.find(a); + if (itA == map.end() || itB == map.end()) { + throw(std::exception()); + }; + return itA->second < itB->second; }); } else { ListSort(keys, type, std::less());