From c0e204310e25c07b1e0698760b704ed769d40217 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 22 Apr 2024 12:25:05 +0200 Subject: [PATCH] refactoring compareThematiquePriority and in cas of equality sort by thematique alphabetical order --- includes/utilities.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/utilities.php b/includes/utilities.php index 69f0591..4eac814 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -128,12 +128,11 @@ function compareThematiquePriority($postA, $postB) $priorityA = $postA->thematique_priority ?? 0; $priorityB = $postB->thematique_priority ?? 0; + $thematiqueA = getPostMainThematique($postA); + $thematiqueB = getPostMainThematique($postB); + if ($priorityA == $priorityB) { - if ($postA->post_date > $postB->post_date) { - return -1; - } else { - return 1; - } + return strcmp($thematiqueA->name, $thematiqueB->name); } if ($priorityA < $priorityB) { return 1;