public function getSortedImages()
    {
        $imagesSort = explode(',', $this->getImagesSort());
        $orderCollection = array_reverse($imagesSort);
        $imagesCollection = $this
            ->getImages()
            ->toArray();

        usort(
            $imagesCollection,
            function (
                \Elcodi\Component\Media\Entity\Interfaces\ImageInterface $a,
                \Elcodi\Component\Media\Entity\Interfaces\ImageInterface $b
            ) use ($orderCollection) {

                $aPos = array_search($a->getId(), $orderCollection);
                $bPos = array_search($b->getId(), $orderCollection);

                return ($aPos < $bPos)
                    ? 1
                    : -1;
            }
        );

        return new ArrayCollection($imagesCollection);
    }
public function getSortedImages()
    {
        $imagesSort = explode(',', $this->getImagesSort());
        $orderCollection = array_reverse($imagesSort);
        $imagesCollection = $this
            ->getImages()
            ->toArray();

        usort(
            $imagesCollection,
            function (
                \Elcodi\Component\Media\Entity\Interfaces\ImageInterface $a,
                \Elcodi\Component\Media\Entity\Interfaces\ImageInterface $b
            ) use ($orderCollection) {

                $aPos = array_search($a->getId(), $orderCollection);
                $bPos = array_search($b->getId(), $orderCollection);

                return ($aPos < $bPos)
                    ? 1
                    : -1;
            }
        );

        return new ArrayCollection($imagesCollection);
    }
public function getSortedImages ( ) { $ imagesSort = explode ( ',' , $ this -> getImagesSort ( ) ) ; $ orderCollection = array_reverse ( $ imagesSort ) ; $ imagesCollection = $ this -> getImages ( ) -> toArray ( ) ; usort ( $ imagesCollection , function ( \ Elcodi \ Component \ Media \ Entity \ Interfaces \ ImageInterface $ a , \ Elcodi \ Component \ Media \ Entity \ Interfaces \ ImageInterface $ b ) use ( $ orderCollection ) { $ aPos = array_search ( $ a -> getId ( ) , $ orderCollection ) ; $ bPos = array_search ( $ b -> getId ( ) , $ orderCollection ) ; return ( $ aPos < $ bPos ) ? 1 : - 1 ; } ) ; return new ArrayCollection ( $ imagesCollection ) ; }
Get sorted images.

@return \Doctrine\Common\Collections\ArrayCollection
Get sorted images .