src/Traits/SortsObjectsCollection.php
protected function sortCollection($objects)
    {
        $class = false;

        if ($objects instanceof Arrayable) {
            $class = get_class($objects);

            $objects = $objects->toArray();
        }

        usort($objects, function ($aObj, $bObj) {
            list($aRank, $bRank) = $this->getRanks($aObj, $bObj);

            if ($this->equals($aRank, $bRank)) {
                return $this->sortByName($aObj, $bObj);
            }

            return $this->sortByValue($aRank, $bRank);
        });

        return $class ? $class::make($objects) : $objects;
    }
protected function sortCollection($objects)
    {
        $class = false;

        if ($objects instanceof Arrayable) {
            $class = get_class($objects);

            $objects = $objects->toArray();
        }

        usort($objects, function ($aObj, $bObj) {
            list($aRank, $bRank) = $this->getRanks($aObj, $bObj);

            if ($this->equals($aRank, $bRank)) {
                return $this->sortByName($aObj, $bObj);
            }

            return $this->sortByValue($aRank, $bRank);
        });

        return $class ? $class::make($objects) : $objects;
    }
protected function sortCollection ( $ objects ) { $ class = false ; if ( $ objects instanceof Arrayable ) { $ class = get_class ( $ objects ) ; $ objects = $ objects -> toArray ( ) ; } usort ( $ objects , function ( $ aObj , $ bObj ) { list ( $ aRank , $ bRank ) = $ this -> getRanks ( $ aObj , $ bObj ) ; if ( $ this -> equals ( $ aRank , $ bRank ) ) { return $ this -> sortByName ( $ aObj , $ bObj ) ; } return $ this -> sortByValue ( $ aRank , $ bRank ) ; } ) ; return $ class ? $ class :: make ( $ objects ) : $ objects ; }
Sort collection of objects by order or class name.

@param $objects

@return array
Sort collection of objects by order or class name .