public function sort($order, $head = true)
    {
        $list = array();

        settype($order, 'array');

        $order = array_unique($order);

        foreach ($order as $item) {
            if (isset($this->_objects[$item])) {
                $list[$item] = $this->_objects[$item];
            }
        }

        foreach ($this->_objects as $key => $object) {
            if (isset($list[$key])) {
                unset($this->_objects[$key]);
            }
        }

        if ($head) {
            $objects = array_merge($list, $this->_objects);
        } else {
            $objects = array_merge($this->_objects, $list);
        }

        $this->_objects = $objects;

        return $this;
    }
public function sort($order, $head = true)
    {
        $list = array();

        settype($order, 'array');

        $order = array_unique($order);

        foreach ($order as $item) {
            if (isset($this->_objects[$item])) {
                $list[$item] = $this->_objects[$item];
            }
        }

        foreach ($this->_objects as $key => $object) {
            if (isset($list[$key])) {
                unset($this->_objects[$key]);
            }
        }

        if ($head) {
            $objects = array_merge($list, $this->_objects);
        } else {
            $objects = array_merge($this->_objects, $list);
        }

        $this->_objects = $objects;

        return $this;
    }
public function sort ( $ order , $ head = true ) { $ list = array ( ) ; settype ( $ order , 'array' ) ; $ order = array_unique ( $ order ) ; foreach ( $ order as $ item ) { if ( isset ( $ this -> _objects [ $ item ] ) ) { $ list [ $ item ] = $ this -> _objects [ $ item ] ; } } foreach ( $ this -> _objects as $ key => $ object ) { if ( isset ( $ list [ $ key ] ) ) { unset ( $ this -> _objects [ $ key ] ) ; } } if ( $ head ) { $ objects = array_merge ( $ list , $ this -> _objects ) ; } else { $ objects = array_merge ( $ this -> _objects , $ list ) ; } $ this -> _objects = $ objects ; return $ this ; }
Rearrange the objects according to the order arrangement. If head is set to true
then the sort order is applied to the head of the objects if false then it's applied
to the tail.

@param array $order An array of order=>name
@param bool  $head  Whether to apply the sort order to the head of array or tail

@return LibBaseTemplateObjectContainer
Rearrange the objects according to the order arrangement . If head is set to true then the sort order is applied to the head of the objects if false then it s applied to the tail .