From 022ccfa4f522bb47309e5137df179ff8c14b2dd7 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 9 Dec 2024 18:53:23 -0300 Subject: [PATCH] Fix --- yarn-project/foundation/src/collection/array.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/foundation/src/collection/array.ts b/yarn-project/foundation/src/collection/array.ts index dc1af0328841..b2ac6bec8733 100644 --- a/yarn-project/foundation/src/collection/array.ts +++ b/yarn-project/foundation/src/collection/array.ts @@ -151,7 +151,7 @@ export function median(arr: number[]) { if (arr.length === 0) { return undefined; } - const sorted = arr.toSorted((a, b) => a - b); + const sorted = [...arr].sort((a, b) => a - b); const mid = Math.floor(sorted.length / 2); return sorted.length % 2 !== 0 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2; }