From bfcdb41b0d88f969b7d37a23bee89ea5fc80eddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katharina=20W=C3=BCnsche?= Date: Mon, 30 Sep 2024 10:34:58 +0200 Subject: [PATCH] chore: sort relations upon retrieval --- lib/group-relations.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/group-relations.ts b/lib/group-relations.ts index e71405a..0571201 100644 --- a/lib/group-relations.ts +++ b/lib/group-relations.ts @@ -40,5 +40,11 @@ export async function loadAndGroupRelations(endpoint: EndpointType, params: endp }); } + Object.keys(groupedResults).forEach((key) => + groupedResults[key]?.sort( + (a, b) => new Date(a.start_date ?? 0).getTime() - new Date(b.start_date ?? 0).getTime(), + ), + ); + return groupedResults; }