From e1c0753d3df1854e892e787adfe25472a3b01cc3 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 31 Aug 2025 14:54:51 +1000 Subject: [PATCH] Qt: Use path as tie breaker when sort titles equal --- src/core/fullscreen_ui.cpp | 6 +++++- src/duckstation-qt/gamelistwidget.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core/fullscreen_ui.cpp b/src/core/fullscreen_ui.cpp index 285d428d4..fec8172f6 100644 --- a/src/core/fullscreen_ui.cpp +++ b/src/core/fullscreen_ui.cpp @@ -7878,7 +7878,11 @@ void FullscreenUI::PopulateGameListEntryList() // fallback to title when all else is equal const int res = StringUtil::CompareNoCase(lhs->GetSortTitle(), rhs->GetSortTitle()); - return reverse ? (res > 0) : (res < 0); + if (res != 0) + return reverse ? (res > 0) : (res < 0); + + // fallback to path when all else is equal + return reverse ? (lhs->path > rhs->path) : (lhs->path < rhs->path); }); } diff --git a/src/duckstation-qt/gamelistwidget.cpp b/src/duckstation-qt/gamelistwidget.cpp index cd15de071..2b93d4e56 100644 --- a/src/duckstation-qt/gamelistwidget.cpp +++ b/src/duckstation-qt/gamelistwidget.cpp @@ -814,7 +814,12 @@ void GameListModel::refresh() bool GameListModel::titlesLessThan(const GameList::Entry* left, const GameList::Entry* right) const { - return (StringUtil::CompareNoCase(left->GetSortTitle(), right->GetSortTitle()) < 0); + const s32 res = StringUtil::CompareNoCase(left->GetSortTitle(), right->GetSortTitle()); + if (res != 0) + return (res < 0); + + // Fallback to path compare if titles are the same. + return (left->path < right->path); } bool GameListModel::lessThan(const QModelIndex& left_index, const QModelIndex& right_index, int column) const