From 17728212c10e2568aef307396fe57c55c9fb1aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Mon, 17 Feb 2025 20:01:06 +0100 Subject: [PATCH] Ignore case in datasets sorting --- src/common/Datasets.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/Datasets.cpp b/src/common/Datasets.cpp index bfbc447..81cdaae 100644 --- a/src/common/Datasets.cpp +++ b/src/common/Datasets.cpp @@ -32,7 +32,12 @@ namespace platform { } sorted_lines.push_back(line); } - std::stable_sort(sorted_lines.begin(), sorted_lines.end()); + sort(sorted_lines.begin(), sorted_lines.end(), [](const auto& lhs, const auto& rhs) { + const auto result = mismatch(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(), [](const auto& lhs, const auto& rhs) {return tolower(lhs) == tolower(rhs);}); + + return result.second != rhs.cend() && (result.first == lhs.cend() || tolower(*result.first) < tolower(*result.second)); + }); + for (const auto& line : sorted_lines) { std::vector tokens = split(line, ';'); std::string name = tokens[0]; @@ -76,6 +81,11 @@ namespace platform { { std::vector result; transform(datasets.begin(), datasets.end(), back_inserter(result), [](const auto& d) { return d.first; }); + sort(result.begin(), result.end(), [](const auto& lhs, const auto& rhs) { + const auto result = mismatch(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(), [](const auto& lhs, const auto& rhs) {return tolower(lhs) == tolower(rhs);}); + + return result.second != rhs.cend() && (result.first == lhs.cend() || tolower(*result.first) < tolower(*result.second)); + }); return result; } bool Datasets::isDataset(const std::string& name) const