Skip to content

Sorting: stable tiebreak so group frames don't reshuffle mid-M+#142

Open
Krathe82 wants to merge 1 commit into
DanderBot:mainfrom
Krathe82:pr/sort-stable-tiebreak
Open

Sorting: stable tiebreak so group frames don't reshuffle mid-M+#142
Krathe82 wants to merge 1 commit into
DanderBot:mainfrom
Krathe82:pr/sort-stable-tiebreak

Conversation

@Krathe82

@Krathe82 Krathe82 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Group/raid frame order rearranges itself during M+ pulls. The sort comparator (SortMembers in BuildSortedNameList) ends with return false for members with equal sort keys — same role with Alphabetical off, or tied names — and Lua's table.sort is not stable. A roster-driven re-sort during an encounter (pet summon/dismiss, role/assist churn → GROUP_ROSTER_UPDATE) can then land same-role players in a different order, changing the rebuilt nameList. The secure header faithfully applies the new order via its Hide/Show cycle, and the frames visibly shuffle.

(The skip-if-unchanged guard on the header attribute is intact and not the cause — it was applying a genuinely different nameList. The non-determinism is upstream of it.)

Fix

Add a deterministic final tiebreak by name so every re-sort of the same roster yields an identical order. Name is invariant for the session and realm-qualified in the nameList, so distinct players never tie:

  • Frames/Headers.lua SortMembers — the live nameList path; covers the player too, which is re-sorted through the same comparator in SORTED mode.
  • Features/Sort.lua CompareUnits + CompareTestData — same return false pattern (legacy/test path).

Trade-off

With Alphabetical off, members of the same role now order by name (previously undefined/arbitrary) instead of reshuffling. That's the deterministic behaviour required to stop the churn.

The sort comparators ended with `return false` for equal-key members (same role
with Alphabetical off, or tied names), and Lua's table.sort is not stable. A
roster-driven re-sort during an encounter (pet summon/dismiss, role/assist churn
-> GROUP_ROSTER_UPDATE) could then land same-role players in a different order,
changing the rebuilt nameList so the secure header reorders the frames — the
"group frames rearrange mid-M+ after pulls" report.

Add a deterministic final tiebreak by name (invariant per session, realm-
qualified in the nameList) so every re-sort of the same roster yields an
identical order:
- Headers.lua SortMembers — the live nameList path; covers the player too, which
  is re-sorted through the same comparator in SORTED mode.
- Sort.lua CompareUnits + CompareTestData — legacy/test path, same pattern.

Trade-off: with Alphabetical off, members of the same role now order by name
(previously undefined/shuffling) rather than an arbitrary order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant