Skip to content

Commit 17f3168

Browse files
Merge pull request #1175 from Mark-Simulacrum/fix-bootstrap-sort
Avoid sort failure due to NaN comparison
2 parents 717937d + 25131f0 commit 17f3168

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

site/static/compare.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,23 @@ <h2>Comparing <span id="stat-header">{{stat}}</span> between <span id="before">{
650650
b: format(b),
651651
percent: 100 * (b - a) / a
652652
};
653-
})
654-
.sort((a, b) => Math.abs(b.percent) - Math.abs(a.percent));
653+
}).sort((a, b) => {
654+
let bp = Math.abs(b.percent);
655+
if (Number.isNaN(bp)) {
656+
bp = 0;
657+
}
658+
let ap = Math.abs(a.percent);
659+
if (Number.isNaN(ap)) {
660+
ap = 0;
661+
}
662+
if (bp < ap) {
663+
return -1;
664+
} else if (bp > ap) {
665+
return 1;
666+
} else {
667+
return a.name.localeCompare(b.name);
668+
}
669+
});
655670
},
656671
before() {
657672
if (!this.data) {

0 commit comments

Comments
 (0)