src/Services/HCMenuService.php
private function sortByWeight(array $adminMenu): array
    {
        usort($adminMenu, function ($a, $b) {
            if (!array_key_exists('priority', $a)) {
                $a['priority'] = 0;
            }

            if (!array_key_exists('priority', $b)) {
                $b['priority'] = 0;
            }

            return $b['priority'] <=> $a['priority'];
        });

        foreach ($adminMenu as &$item) {
            if (array_key_exists('children', $item)) {
                $item['children'] = $this->sortByWeight($item['children']);
            }
        }

        return $adminMenu;
    }
private function sortByWeight(array $adminMenu): array
    {
        usort($adminMenu, function ($a, $b) {
            if (!array_key_exists('priority', $a)) {
                $a['priority'] = 0;
            }

            if (!array_key_exists('priority', $b)) {
                $b['priority'] = 0;
            }

            return $b['priority'] <=> $a['priority'];
        });

        foreach ($adminMenu as &$item) {
            if (array_key_exists('children', $item)) {
                $item['children'] = $this->sortByWeight($item['children']);
            }
        }

        return $adminMenu;
    }
private function sortByWeight ( array $ adminMenu ) : array { usort ( $ adminMenu , function ( $ a , $ b ) { if ( ! array_key_exists ( 'priority' , $ a ) ) { $ a [ 'priority' ] = 0 ; } if ( ! array_key_exists ( 'priority' , $ b ) ) { $ b [ 'priority' ] = 0 ; } return $ b [ 'priority' ] <=> $ a [ 'priority' ] ; } ) ; foreach ( $ adminMenu as & $ item ) { if ( array_key_exists ( 'children' , $ item ) ) { $ item [ 'children' ] = $ this -> sortByWeight ( $ item [ 'children' ] ) ; } } return $ adminMenu ; }
Sort admin menu by given priority DESC

@param array $adminMenu
@return array
Sort admin menu by given priority DESC