Skip to content

Commit

Permalink
Fix sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Rodriguez Baquero committed Jul 3, 2023
1 parent cde88b4 commit 9b18d73
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const computeStats = (
{ "1d": 0, "7d": 0 }
);

const medianTTFBSortedNodes = nodes.sort((a, b) => b.ttfbStats.p50_12h - a.ttfbStats.p50_12h);
let medianTTFBLastValidIndex = medianTTFBSortedNodes.findLastIndex(node => Number.isInteger(node.ttfbStats.p50_12h));
const medianTTFBSortedNodes = nodes.sort((a, b) => (b.ttfbStats.p50_12h ?? 0) - (a.ttfbStats.p50_12h ?? 0));
let medianTTFBLastValidIndex = medianTTFBSortedNodes.findLastIndex(node => Number.isInteger(node.ttfbStats.p50_12h) && node.ttfbStats.p50_12h > 0);
if (medianTTFBLastValidIndex === -1) {
medianTTFBLastValidIndex = 0;
}
Expand Down

0 comments on commit 9b18d73

Please sign in to comment.