From 7a22bd0570589173b6ec88df05669495a859310f Mon Sep 17 00:00:00 2001 From: francesco Date: Fri, 13 Dec 2024 18:51:24 +0100 Subject: [PATCH] Collections now preserving order when joined with external config --- packages/collection_editor/src/utils/collections.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/collection_editor/src/utils/collections.ts b/packages/collection_editor/src/utils/collections.ts index 6feee88c9..efd0fbc86 100644 --- a/packages/collection_editor/src/utils/collections.ts +++ b/packages/collection_editor/src/utils/collections.ts @@ -25,6 +25,10 @@ export const mergeCollections = (baseCollections: EntityCollection[], console.debug("Collections specified in code:", baseCollections); console.debug("Collections stored in the backend", storedCollections); const result = joinCollectionLists(baseCollections, storedCollections, [], modifyCollection); + + // sort the collections so they are in the same order as the base collections + result.sort((a, b) => baseCollections.findIndex(c => c.id === a.id) - baseCollections.findIndex(c => c.id === b.id)); + console.debug("Collections after joining:", result); return result; }