Skip to content

Commit 224ea18

Browse files
feat: add complexity sort
1 parent bf19155 commit 224ea18

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

website/src/catalog/RuleList.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ruleMetaData = computed(() => getRuleMetaData(props.filter, sortBy.value))
3434
<select v-model="sortBy">
3535
<option value="name">Name</option>
3636
<option value="lang">Lang</option>
37+
<option value="complexity">Complexity</option>
3738
</select>
3839
<IconDown/>
3940
</label>

website/src/catalog/data.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ export function getRuleMetaData(filter: Filter, sortBy = 'name') {
1919
}).toSorted((a, b) => {
2020
if (sortBy === 'name') {
2121
return a.name.localeCompare(b.name)
22-
} else {
22+
} else if (sortBy === 'lang') {
2323
return a.language.localeCompare(b.language)
24+
} else if (sortBy === 'complexity') {
25+
const complexityA = a.rules.length + a.features.length
26+
const complexityB = b.rules.length + b.features.length
27+
return complexityA - complexityB
28+
} else {
29+
return 0
2430
}
2531
})
2632
}

0 commit comments

Comments
 (0)