From 19bbbf994c541e009fc88ab5366c8e21f27d8a49 Mon Sep 17 00:00:00 2001 From: Zaid Ismail <64991232+zaid-ismail031@users.noreply.github.com> Date: Thu, 30 Jan 2025 14:09:50 +0200 Subject: [PATCH] Fix game title sorting bug from Issue #2260 (#2284) * Fix alphabetical sorting bug caused by case-sensitive string comparisons in GameListFrame. * Fix bug with incorrect use of std::tolower. * Fix clang-format error. --------- Co-authored-by: Zaid Ismail --- src/qt_gui/game_list_frame.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/qt_gui/game_list_frame.h b/src/qt_gui/game_list_frame.h index 8c6fcb1e2..90d021093 100644 --- a/src/qt_gui/game_list_frame.h +++ b/src/qt_gui/game_list_frame.h @@ -3,6 +3,9 @@ #pragma once +#include // std::transform +#include // std::tolower + #include #include #include @@ -65,8 +68,12 @@ public: static bool CompareStringsAscending(GameInfo a, GameInfo b, int columnIndex) { switch (columnIndex) { - case 1: - return a.name < b.name; + case 1: { + std::string name_a = a.name, name_b = b.name; + std::transform(name_a.begin(), name_a.end(), name_a.begin(), ::tolower); + std::transform(name_b.begin(), name_b.end(), name_b.begin(), ::tolower); + return name_a < name_b; + } case 2: return a.compatibility.status < b.compatibility.status; case 3: @@ -90,8 +97,12 @@ public: static bool CompareStringsDescending(GameInfo a, GameInfo b, int columnIndex) { switch (columnIndex) { - case 1: - return a.name > b.name; + case 1: { + std::string name_a = a.name, name_b = b.name; + std::transform(name_a.begin(), name_a.end(), name_a.begin(), ::tolower); + std::transform(name_b.begin(), name_b.end(), name_b.begin(), ::tolower); + return name_a > name_b; + } case 2: return a.compatibility.status > b.compatibility.status; case 3: