Skip to content

Open source personal finance application

fix: use toSorted() instead of Array.from().sort() in categories store

Ilya Komichev397f32ccbdc9
diff --git a/app/components/categories/useCategoriesStore.ts b/app/components/categories/useCategoriesStore.ts
index bc700d07..ea544461 100644
--- a/app/components/categories/useCategoriesStore.ts
+++ b/app/components/categories/useCategoriesStore.ts
@@ -128,7 +128,7 @@ export const useCategoriesStore = defineStore('categories', (): CategoriesStore
}
// Filter valid categories and pick top N by most recent usage
- const sortedEntries: [CategoryId, number][] = Array.from(latestDateByCategory.entries()).sort(([, dateA], [, dateB]) => dateB - dateA)
+ const sortedEntries: [CategoryId, number][] = [...latestDateByCategory.entries()].toSorted(([, dateA], [, dateB]) => dateB - dateA)
const recentIds = sortedEntries.reduce<CategoryId[]>((acc, [categoryId]) => {
if (acc.length >= maxCategories)