public function groupBy($group=null)
    {
        $group = LambdaUtils::toSelectCallable($group);

        $result = new ObjectArray(array());
        if($this instanceof ObjectArray)
        {
            $result = $this->newInstance();
        }

        foreach($this as $record)
        {
            $key = call_user_func($group, $record);

            $data = array();
            if($this->__converter instanceof IListConverter)
            {
                $data = $this->newConverterInstance();
            }
            $newitemtype = new ArrayList($data);

            $result->get($key, $newitemtype, true)->add($record);
        }

        return $result;
    }
public function groupBy($group=null)
    {
        $group = LambdaUtils::toSelectCallable($group);

        $result = new ObjectArray(array());
        if($this instanceof ObjectArray)
        {
            $result = $this->newInstance();
        }

        foreach($this as $record)
        {
            $key = call_user_func($group, $record);

            $data = array();
            if($this->__converter instanceof IListConverter)
            {
                $data = $this->newConverterInstance();
            }
            $newitemtype = new ArrayList($data);

            $result->get($key, $newitemtype, true)->add($record);
        }

        return $result;
    }
public function groupBy ( $ group = null ) { $ group = LambdaUtils :: toSelectCallable ( $ group ) ; $ result = new ObjectArray ( array ( ) ) ; if ( $ this instanceof ObjectArray ) { $ result = $ this -> newInstance ( ) ; } foreach ( $ this as $ record ) { $ key = call_user_func ( $ group , $ record ) ; $ data = array ( ) ; if ( $ this -> __converter instanceof IListConverter ) { $ data = $ this -> newConverterInstance ( ) ; } $ newitemtype = new ArrayList ( $ data ) ; $ result -> get ( $ key , $ newitemtype , true ) -> add ( $ record ) ; } return $ result ; }
Group fields by condition
@param callable|string|null $group
@return \PerrysLambda\ArrayBase
Group fields by condition