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;