Skip to content

Commit

Permalink
Improve merging of tags by simple drag and drop hoarder-app#144
Browse files Browse the repository at this point in the history
improved the usage sorter to additionally compare by name if the usage is the same
  • Loading branch information
kamtschatka committed May 17, 2024
1 parent cb58728 commit fc4f359
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/web/components/dashboard/tags/AllTagsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ function DeleteAllUnusedTags({ numUnusedTags }: { numUnusedTags: number }) {
);
}

const byUsageSorter = (a: ZGetTagResponse, b: ZGetTagResponse) =>
b.count - a.count;
const byUsageSorter = (a: ZGetTagResponse, b: ZGetTagResponse) => {
// Sort by name if the usage is the same to get a stable result
if (b.count == a.count) {
return byNameSorter(a, b);
}
return b.count - a.count;
};
const byNameSorter = (a: ZGetTagResponse, b: ZGetTagResponse) =>
a.name.localeCompare(b.name, undefined, { sensitivity: "base" });

Expand Down

0 comments on commit fc4f359

Please sign in to comment.