From 927480748c7dd3548b371389210d4fd25e6fae32 Mon Sep 17 00:00:00 2001 From: Phoenix Meadowlark <40036383+phoenix-meadowlark@users.noreply.github.com> Date: Sat, 11 Apr 2020 10:34:48 -0700 Subject: [PATCH] Update to provide consistent cross-browser behavior. Changes the sorting in `generate_possibilities` to have the intended effect. The old version worked on firefox, but did not sort the list on chrome because `a.weekMax < b.weekMax` does not return `-1` if `a.weekMax > b.weekMax`. --- js/predictions.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/predictions.js b/js/predictions.js index fc1917b..96fe462 100644 --- a/js/predictions.js +++ b/js/predictions.js @@ -654,7 +654,15 @@ function analyze_possibilities(sell_prices, first_buy, previous_pattern) { poss.weekMax = Math.max(...weekMaxes); } - generated_possibilities.sort((a, b) => a.weekMax < b.weekMax); + generated_possibilities.sort((a, b) => { + if (a.weekMax < b.weekMax) { + return 1; + } else if (a.weekMax > b.weekMax) { + return -1; + } else { + return 0; + } + }); return generated_possibilities; }