]> git.cworth.org Git - lmno-server/commitdiff
empathy: Alphabetize list before sending it out for judging
authorCarl Worth <cworth@cworth.org>
Fri, 12 Jun 2020 02:58:33 +0000 (19:58 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 12 Jun 2020 02:58:33 +0000 (19:58 -0700)
This should make judging much easier.

Fix is confirmed with the existing test case (which is updated to
match the new behavior).

empathy.js
test

index 028117db344b575919a86da6b6979fb967e7c518..759b486f8b58b1814299c1fe6863bb17109b2917 100644 (file)
@@ -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 7113659eb5d40f2c7fadb3572ec53eed5f2b8dd9..e56cc93f4e1e8f9c8ea6d9db7f93b3555f54039f 100755 (executable)
--- 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"