FluidTYPO3\Vhs\ViewHelpers\Iterator\SortViewHelper::sortObjectStorage PHP Method

sortObjectStorage() protected method

Sort an ObjectStorage instance
protected sortObjectStorage ( TYPO3\CMS\Extbase\Persistence\ObjectStorage $storage ) : TYPO3\CMS\Extbase\Persistence\ObjectStorage
$storage TYPO3\CMS\Extbase\Persistence\ObjectStorage
return TYPO3\CMS\Extbase\Persistence\ObjectStorage
    protected function sortObjectStorage($storage)
    {
        /** @var ObjectManager $objectManager */
        $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
        /** @var ObjectStorage $temp */
        $temp = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
        foreach ($storage as $item) {
            $temp->attach($item);
        }
        $sorted = $this->sortArray($storage);
        $storage = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
        foreach ($sorted as $item) {
            $storage->attach($item);
        }
        return $storage;
    }