From d40bfc6f0942b59e790edde921e272dc3baba92c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 5 Sep 2026 09:13:46 +0900 Subject: [PATCH] fix: Cannot sort observable array --- shared/utils/naturalSort.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shared/utils/naturalSort.ts b/shared/utils/naturalSort.ts index f83b544db6..844fc3ac1b 100644 --- a/shared/utils/naturalSort.ts +++ b/shared/utils/naturalSort.ts @@ -40,9 +40,10 @@ function naturalSortBy( }) : sorter; - return items.sort((a: T, b: T) => - sort(getSortByField(a, key), getSortByField(b, key)) - ); + // Sort a copy, `items` may be an observable array which cannot be sorted in place. + return items + .slice() + .sort((a: T, b: T) => sort(getSortByField(a, key), getSortByField(b, key))); } export default naturalSortBy;