protected function sortItems(array $items, string $key = 'order'): array
    {
        $cmp = function (&$a, &$b) use (&$cmp, $key) {
            if (!empty($a['children'])) {
                usort($a['children'], $cmp);
            }

            if (!empty($b['children'])) {
                usort($b['children'], $cmp);
            }

            return $a[$key] > $b[$key];
        };

        usort($items, $cmp);

        return $items;
    }
protected function sortItems(array $items, string $key = 'order'): array
    {
        $cmp = function (&$a, &$b) use (&$cmp, $key) {
            if (!empty($a['children'])) {
                usort($a['children'], $cmp);
            }

            if (!empty($b['children'])) {
                usort($b['children'], $cmp);
            }

            return $a[$key] > $b[$key];
        };

        usort($items, $cmp);

        return $items;
    }
protected function sortItems ( array $ items , string $ key = 'order' ) : array { $ cmp = function ( & $ a , & $ b ) use ( & $ cmp , $ key ) { if ( ! empty ( $ a [ 'children' ] ) ) { usort ( $ a [ 'children' ] , $ cmp ) ; } if ( ! empty ( $ b [ 'children' ] ) ) { usort ( $ b [ 'children' ] , $ cmp ) ; } return $ a [ $ key ] > $ b [ $ key ] ; } ; usort ( $ items , $ cmp ) ; return $ items ; }
Method for sorting array items by specified key.

@param mixed[] $items List of items to be sorted
@param string $key Sort-by key
@return mixed[]
Method for sorting array items by specified key .