diff --git a/app/components/Filter/TagSelect.vue b/app/components/Filter/TagSelect.vue index 8dd6688..9dd7dfb 100644 --- a/app/components/Filter/TagSelect.vue +++ b/app/components/Filter/TagSelect.vue @@ -35,12 +35,12 @@ return (rawTags.value ?? []) .filter((tag) => (tagCount[tag.uuid] ?? 0) > 0) - .sort((a, b) => { - const diff = (tagCount[b.uuid] ?? 0) - (tagCount[a.uuid] ?? 0); - if (diff !== 0) return diff; - - return a.name.localeCompare(b.name); - }); + .sort( + (a, b) => + b.group - a.group || + (tagCount[b.uuid] ?? 0) - (tagCount[a.uuid] ?? 0) || + a.name.localeCompare(b.name), + ); }); diff --git a/app/components/Todo/TodoShell.vue b/app/components/Todo/TodoShell.vue index 058072f..51b9833 100644 --- a/app/components/Todo/TodoShell.vue +++ b/app/components/Todo/TodoShell.vue @@ -22,7 +22,7 @@ .filter( (tag) => !props.interactive || !tagsFilter.value.includes(tag.uuid), ) - .sort((a, b) => a.name.localeCompare(b.name)); + .sort((a, b) => b.group - a.group || a.name.localeCompare(b.name)); }); function onTagPress(tag: LabelType) { diff --git a/app/components/Utils/Label/TagSelect.vue b/app/components/Utils/Label/TagSelect.vue index 9e57ff4..0b4626a 100644 --- a/app/components/Utils/Label/TagSelect.vue +++ b/app/components/Utils/Label/TagSelect.vue @@ -56,13 +56,12 @@ let filteredTags = (rawTags.value ?? []) .filter((tag) => (activeTagCount[tag.uuid] ?? 0) > 0) - .sort((a, b) => { - const diff = - (activeTagCount[b.uuid] ?? 0) - (activeTagCount[a.uuid] ?? 0); - if (diff !== 0) return diff; - - return a.name.localeCompare(b.name); - }); + .sort( + (a, b) => + b.group - a.group || + (activeTagCount[b.uuid] ?? 0) - (activeTagCount[a.uuid] ?? 0) || + a.name.localeCompare(b.name), + ); const tagCount = todos.value .flatMap((todo) => todo.tags?.map((tag) => tag.uuid) ?? []) @@ -75,12 +74,12 @@ ); let otherTags = (rawTags.value ?? []) .filter((tag) => !filteredTags.includes(tag)) - .sort((a, b) => { - const diff = (tagCount[b.uuid] ?? 0) - (tagCount[a.uuid] ?? 0); - if (diff !== 0) return diff; - - return a.name.localeCompare(b.name); - }); + .sort( + (a, b) => + b.group - a.group || + (tagCount[b.uuid] ?? 0) - (tagCount[a.uuid] ?? 0) || + a.name.localeCompare(b.name), + ); return { filteredTags, otherTags }; });