From e48e6f5f3a4edb74eac839727533d702119bf9a8 Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Mon, 26 Feb 2007 09:00:55 +0000 Subject: [PATCH] Cleverer way to sort users git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1517 839d8a87-29fc-0310-9880-83ba4fa771e5 --- modules/lists.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/lists.php b/modules/lists.php index 9ae5ce2..0e220ff 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -272,6 +272,17 @@ class ListsModule extends PLModule } } + function compare($a, $b) + { + if ($a['promo'] == $b['promo']) { + if ($a['nom'] == $b['nom']) { + return strcmp($a['prenom'], $b['prenom']); + } + return strcmp($a['nom'], $b['nom']); + } + return $a['promo'] - $b['promo']; + } + function _get_list($offset, $limit) { global $platal; @@ -292,9 +303,7 @@ class ListsModule extends PLModule $total--; } } - uasort($membres, create_function('$a,$b', 'return $a["promo"] > $b["promo"] || ' - . '($a["promo"] == $b["promo"] && (strcmp($a["nom"], $b["nom"]) > 0 || ' - . '($a["nom"] == $b["nom"] && strcmp($a["prenom"], $b["prenom"]) > 0)));')); + uasort($membres, array($this, 'compare')); return array($total, $membres); } -- 2.1.4