Skip to content

Commit e73fd2e

Browse files
Sort items in the datahub (#815)
* sorting datahub * not sorting groups first * case insensitive compares
1 parent 6c097cb commit e73fd2e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Controller/ConfigController.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,18 @@ public function listAction(Request $request): JsonResponse
115115
}
116116
}
117117

118-
foreach ($groups as $group) {
119-
$tree[] = $group;
118+
$sortFunc = fn($a, $b) => strtolower($a['text']) <=> strtolower($b['text']);
119+
120+
//sort group children
121+
foreach($groups as &$group){
122+
usort($group['children'], $sortFunc);
120123
}
121124

125+
//sort items
126+
$tree = array_merge($tree, $groups);
127+
128+
usort($tree, $sortFunc);
129+
122130
return $this->json($tree);
123131
}
124132

0 commit comments

Comments
 (0)