Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Features/Sort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ function Sort:CompareUnits(unitA, unitB, db)
return nameA < nameB
end
end


-- Deterministic final tiebreak: equal-key units need a stable order, or the
-- unstable Lua table.sort reshuffles them on each re-sort (group-frame shuffle
-- during M+ pulls). Mirrors Headers.lua SortMembers.
local tieA = UnitName(unitA) or ""
local tieB = UnitName(unitB) or ""
if tieA ~= tieB then return tieA < tieB end
return false
end

Expand Down Expand Up @@ -267,7 +273,12 @@ function Sort:CompareTestData(dataA, dataB, db)
return nameA < nameB
end
end


-- Deterministic final tiebreak (see CompareUnits) so test-mode sorting is
-- stable across re-sorts too.
local tieA = dataA.name or ""
local tieB = dataB.name or ""
if tieA ~= tieB then return tieA < tieB end
return false
end

Expand Down
12 changes: 11 additions & 1 deletion Frames/Headers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4878,9 +4878,19 @@ function DF:BuildSortedNameList(members, db, selfPosition, includesPlayer)
return a.name < b.name
end
end
-- Deterministic final tiebreak. Without one, members with equal sort keys
-- (same role, Alphabetical off) have no defined order, and Lua's table.sort
-- is NOT stable — so a roster-driven re-sort mid-encounter reshuffles
-- same-role players, making the group frames rearrange during M+ pulls.
-- Break ties by name (invariant for the session, and realm-qualified in the
-- nameList so cross-realm names don't collide) so every re-sort of the same
-- roster produces an identical order and the secure header never reorders.
if a.name ~= b.name then
return a.name < b.name
end
return false
end

-- Sort non-player members
table.sort(sortedMembers, SortMembers)

Expand Down