private function sortByArray($items, array $order)
    {
        $unordered = [];
        foreach ($items as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($order as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
private function sortByArray($items, array $order)
    {
        $unordered = [];
        foreach ($items as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($order as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
private function sortByArray ( $ items , array $ order ) { $ unordered = [ ] ; foreach ( $ items as $ content ) { $ unordered [ $ content -> getId ( ) ] = $ content ; } $ ordered = [ ] ; foreach ( $ order as $ id ) { if ( isset ( $ unordered [ $ id ] ) ) { $ ordered [ ] = $ unordered [ $ id ] ; } } return $ ordered ; }
Sort the items by an array of ids.

@param ArrayCollection $items
@param array           $order

@return array
Sort the items by an array of ids .