Fix Priority Sort Corrected and expanded priority sort logic to sort by: First constant, then normal, then disabled, then by comment.

28861660ef5986223f31d8cf54da4c18406a7c2c

Khreed <135299775+KhreedAI@users.noreply.github.com>

1 files changed, +27 -4Ignore whitespace
public/scripts/world-info.js+27 -4
@@ -1678,11 +1678,34 @@ export function sortWorldInfoEntries(data, { customSort = null } = {}) {
16781678 return aValue - bValue;
16791679 };
16801680 } else if (sortRule === 'priority') {
16811681 // First constant, then normal, then disabled, then by comment.
16821682 primarySort = (a, b) => {
1683- const aValue = a.constant ? 0 : a.disable ? 2 : 1;
1683+ // Determine priority based on disable and constant flags
16841684 const bValueaPriority = ba.constantdisable ? 02 : ba.disableconstant ? 20 : 1;
1685- return aValue - bValue;
1685+ const bPriority = b.disable ? 2 : b.constant ? 0 : 1;
1686+
1687+ // Compare priorities first
1688+ if (aPriority !== bPriority) {
1689+ return aPriority - bPriority;
1690+ }
1691+
1692+ // Normalize comments for comparison, handling null/undefined
1693+ const commentA = a.comment ? a.comment.toLowerCase() : '';
1694+ const commentB = b.comment ? b.comment.toLowerCase() : '';
1695+
1696+ // Assign constant values for further comparison
1697+ const constantA = a.constant ? 0 : 1;
1698+ const constantB = b.constant ? 0 : 1;
1699+
1700+ // If priorities are equal, compare constants
1701+ if (aPriority === bPriority) {
1702+ if (constantA !== constantB) {
1703+ return constantA - constantB;
1704+ }
1705+ }
1706+
1707+ // Finally, compare comments alphabetically
1708+ return commentA.localeCompare(commentB);
16861709 };
16871710 } else {
16881711 primarySort = (a, b) => {