| 1678 | 1678 | return aValue - bValue; |
| 1679 | 1679 | }; |
| 1680 | 1680 | } else if (sortRule === 'priority') { |
| 1681 | 1681 | // First constant, then normal, then disabled, then by comment. |
| 1682 | 1682 | primarySort = (a, b) => { |
| 1683 | | - // Determine priority based on disable and constant flags |
| 1683 | + const aValue = a.disable ? 2 : a.constant ? 0 : 1; |
| 1684 | 1684 | const aPrioritybValue = ab.disable ? 2 : ab.constant ? 0 : 1; |
| 1685 | | - const bPriority = b.disable ? 2 : b.constant ? 0 : 1; |
| 1685 | + return aValue - bValue; |
| 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); |
| 1709 | 1686 | }; |
| 1710 | 1687 | } else { |
| 1711 | 1688 | primarySort = (a, b) => { |