Skip to content

Commit

Permalink
order by entity, then by identifier for better searching
Browse files Browse the repository at this point in the history
  • Loading branch information
josiaskas committed Oct 5, 2023
1 parent 9db00c6 commit 4139e15
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/builder/GroupCtrlSlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ export default defineComponent({
orderedRules(): RuleDefinitionWithChain[] {
const rules = [...this.groupCtrl.rules] as RuleDefinitionWithChain[];
return rules.sort((a, b) => {
if (a.chain !== undefined && b.chain !== undefined) {
if (a.chain.length > b.chain?.length) {
return 1;
} else if (a.chain?.length < b.chain?.length) {
return -1;
const aChain = a.chain || [];
const bChain = b.chain || [];
for (let i = 0; i < Math.min(aChain.length, bChain.length); i++) {
const chainComparison = aChain[i].localeCompare(bChain[i]);
if (chainComparison !== 0) {
return chainComparison;
}
}
if (aChain.length !== bChain.length) {
return aChain.length - bChain.length;
}
return a.identifier.localeCompare(b.identifier);
});
},
Expand Down

0 comments on commit 4139e15

Please sign in to comment.