From c16b6b04ff52b62a375fc9044f9ca0c3b98bf7cb Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:51:18 -0700 Subject: [PATCH] case insensitive sort answers --- cmd/server/internal/public/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/server/internal/public/index.html b/cmd/server/internal/public/index.html index eb569d4..bcae208 100644 --- a/cmd/server/internal/public/index.html +++ b/cmd/server/internal/public/index.html @@ -60,10 +60,15 @@ } document.getElementById("answers-list").hidden = false; http("GET", `/api/v1/questions/${g_live_question.ID}/answers`, (body) => { - let answers = JSON.parse(body); + let answers = JSON.parse(body).map((a) => a.Text); + answers.sort((a, b) => { + a = a.toLowerCase(); + b = b.toLowerCase(); + return (a > b) - (a < b) + }); let result = ""; for (let i of answers) - result += `
  • ${i.Text}
  • `; + result += `
  • ${i}
  • `; document.getElementById("answers-list").innerHTML = ``; }); }