diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 4a982d5..2e5e77e 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -33,12 +33,7 @@ class MainController extends AbstractController // Collect servers info $servers = []; - foreach ((array) $entityManagerInterface->getRepository(Server::class)->findBy( - [], - [ - 'online' => 'desc' - ] - ) as $server) + foreach ((array) $entityManagerInterface->getRepository(Server::class)->findAll() as $server) { // Init defaults $status = false; @@ -106,10 +101,21 @@ class MainController extends AbstractController 'updated' => $server->getUpdated(), 'online' => $server->getOnline(), 'info' => $info, - 'status' => $status + 'status' => $status, + 'sort' => empty($info['Players']) ? 0 : (int) $info['Players'] ]; } + // Sort by players + array_multisort( + array_column( + $servers, + 'sort' + ), + SORT_DESC, + $servers + ); + return $this->render( 'default/main/index.html.twig', [