From 3bea0c1227f9ec32f427155393e3f9403b6d7b9c Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Wed, 5 Jul 2017 12:09:25 -0400 Subject: [PATCH] adjusting the dataCategories sortParentChild function the parentChild sorting function in the dataCategories data class file needed to add the tilde appended to not just the parent but the child as well in order to properly sort categories that are similar in name except for numbers or characters at the end --- classes/data/dataCategories.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/data/dataCategories.php b/classes/data/dataCategories.php index eabf097..aa4dd0b 100644 --- a/classes/data/dataCategories.php +++ b/classes/data/dataCategories.php @@ -403,25 +403,24 @@ class GlmDataEventsCategories extends GlmDataAbstract if (!is_array($array) || count($array) == 0) { return false; } - + // Do a sort by custom function with it included in the call // This lets me directly use $name and $parent in the sort function uasort($array, function ($a, $b) use ($name, $parent) { - // If there's a parent, append the name of this entry to the parent // The '~~~' simply keeps appended strings from any chance of a match with something else if ($a[$parent]['value']) { $aVal = $a[$parent]['name'].'~~~'.$a['name']; } else { // Otheriwse just use the name. - $aVal = $a['name']; + $aVal = $a['name'].'~~~'; } // Same for b value if ($b[$parent]['value']) { $bVal = $b[$parent]['name'].'~~~'.$b['name']; } else { - $bVal = $b['name']; + $bVal = $b['name'].'~~~'; } if ($aVal > $bVal) { -- 2.17.1