From bd9a1f886e3bdd78852f384ddf6152d777740f7d Mon Sep 17 00:00:00 2001 From: novgorodschi catalin Date: Mon, 29 Jun 2026 07:46:57 +0300 Subject: [PATCH] Fix #296 Fix TREASURY ARTEFACTS AREA SORTING --- Templates/Build/27_1.tpl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Templates/Build/27_1.tpl b/Templates/Build/27_1.tpl index a8df4a69..d8212fda 100644 --- a/Templates/Build/27_1.tpl +++ b/Templates/Build/27_1.tpl @@ -3,7 +3,7 @@ ################################################################################# ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ## ## --------------------------------------------------------------------------- ## -## Filename : TREASURY ARTEFACTS AREEA ## +## Filename : TREASURY ARTEFACTS AREA ## ## Type : BUILDING TEMPLATE ## ## --------------------------------------------------------------------------- ## ## Refactored by : Shadow ## @@ -88,11 +88,12 @@ if(count($artifacts) == 0) { foreach($artifacts as $artifact){ $coordinates = $database->getCoor($artifact['vref']); $distance = $database->getDistance($village->coor['x'], $village->coor['y'], $coordinates['x'], $coordinates['y']); - // unique key prevents overwriting when 2 artifacts are at the same distance - $rows[$distance.'_'.$artifact['id']] = ['dist' => $distance, 'data' => $artifact]; + $rows[] = ['dist' => $distance, 'data' => $artifact]; } - - ksort($rows); + + usort($rows, function($a, $b) { + return $a['dist'] <=> $b['dist']; + }); foreach($rows as $row) { $distance = $row['dist'];