From 1d45f936729876a5ea6986be57b2fe005adac376 Mon Sep 17 00:00:00 2001 From: Niko Bochan Date: Mon, 1 Dec 2014 12:29:20 +0100 Subject: [PATCH] use id instead of title --- CRM/Utils/Sort.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CRM/Utils/Sort.php b/CRM/Utils/Sort.php index 36c61abd21..789c585587 100644 --- a/CRM/Utils/Sort.php +++ b/CRM/Utils/Sort.php @@ -275,17 +275,23 @@ class CRM_Utils_Sort { } /** - * Universal callback function for sorting by weight + * Universal callback function for sorting by weight or id * * @param $a * @param $b * - * @return array of items sorted by weight + * @return array of items sorted by weight (or id if weights are the same) * @access public */ static function cmpFunc($a, $b) { if($a['weight'] == $b['weight']) { - return strcmp($a['title'], $b['title']); + $result = strcmp($a['id'], $b['id']); + // return -1 for equal ids to keep the behavior + // of the original function for equal weights + if ($result == 0) { + return -1; + } + return $result; } return ($a['weight'] <= $b['weight']) ? -1 : 1; } -- 2.25.1