From 40d0914b478c87e67e33bc24e53305c626398052 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 7 Feb 2022 11:24:53 +0100 Subject: [PATCH] sort poll display --- src/Controller/api/v1/PollController.php | 3 ++- src/Entity/Poll.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Controller/api/v1/PollController.php b/src/Controller/api/v1/PollController.php index 5499a76..9f0e596 100644 --- a/src/Controller/api/v1/PollController.php +++ b/src/Controller/api/v1/PollController.php @@ -104,7 +104,8 @@ class PollController extends EmailsController { } else { // free access to poll - return $this->json( sort( $poll->display()) ); + $pollResult = $poll->display(); + return $this->json( $pollResult ); } } diff --git a/src/Entity/Poll.php b/src/Entity/Poll.php index ff7a513..0263144 100755 --- a/src/Entity/Poll.php +++ b/src/Entity/Poll.php @@ -243,13 +243,13 @@ class Poll $content['admin_key'] = $this->getAdminKey(); $content['password_hash'] = $this->getPassword(); $content['id'] = $this->getId(); - + ksort($content); return $content; } // counts each number of answer for this choice - public function display() + public function display(): array { $computedAnswers = $this->computeAnswers(); @@ -289,6 +289,7 @@ class Poll 'votes_allowed' => $this->getVotesAllowed(), 'votes_max' => $this->getVotesMax(), ]; + ksort($resp); return $resp; }