Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Dec 9, 2024
1 parent 351523c commit 4ac396f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/collection/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 4ac396f

Please sign in to comment.