From e181d1b70ae0fdb3499852a5c8820617a533924d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 11 Jun 2020 19:58:33 -0700 Subject: [PATCH] empathy: Alphabetize list before sending it out for judging This should make judging much easier. Fix is confirmed with the existing test case (which is updated to match the new behavior). --- empathy.js | 4 +++- test | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/empathy.js b/empathy.js index 028117d..759b486 100644 --- a/empathy.js +++ b/empathy.js @@ -144,7 +144,9 @@ class Empathy extends Game { } } - this.state.ambiguities = Object.values(word_map); + this.state.ambiguities = Object.values(word_map).sort((a,b) => { + return a.toLowerCase().localeCompare(b.toLowerCase()); + }); this.broadcast_event_object('ambiguities', this.state.ambiguities); } diff --git a/test b/test index 7113659..e56cc93 100755 --- a/test +++ b/test @@ -533,7 +533,7 @@ empathy_ambiguities() TEST "Received all unique words" # echo here is to strip newlines result=$(echo $(empathy_ambiguities $alice)) -test "$result" = '"sun" "sand" "water" "people" "sands" "SunLight" "towels" "SunShine" "Grains of Sand" "wafer"' +test "$result" = '"Grains of Sand" "people" "sand" "sands" "sun" "SunLight" "SunShine" "towels" "wafer" "water"' TEST_END TEST "Submit word groups from alice" -- 2.43.0