Sort In Grid View

hi all,is there any way to sort the content displayed in grid view?if so kindly help me.

Thanks in advance :)

<?php

  &#036;duplicateData = Yii::app()-&gt;db-&gt;createCommand()


            -&gt;select('*')


            -&gt;from('mail')


            -&gt;queryAll();


 &#036;dataProvider = new CArrayDataProvider(&#036;duplicateData, array(


                    'pagination' =&gt; array(


                            'pageSize' =&gt; 10,


                    ),


            ));








 &#036;this-&gt;widget('zii.widgets.grid.CGridView', array(


    


    'dataProvider' =&gt; &#036;dataProvider-&gt;search(),


    


            array(


                    'name'   =&gt; 'E_Id',


                    'header' =&gt; 'Email Id'


            ),


            array(


                    'name'   =&gt; 'Receiver',


                    'header' =&gt; 'Receiver'


            ),


    )

));

?&gt;

In my code I use this


    public function search()

    {

        $criteria=new CDbCriteria;


        $criteria->compare('t.id',$this->id);

        $criteria->compare('typeId',$this->typeId);

        $criteria->compare('countryId',$this->countryId);

        $criteria->compare('t.title',$this->title,true);

        $criteria->compare('content',$this->content,true);

        $criteria->compare('created',$this->created,true);

        $criteria->compare('deleted',$this->deleted,true);


        $criteria->with=array('type', 'country');


        return new CActiveDataProvider(

            $this,

            array(

                'criteria'=>$criteria,

                'sort'=>array(

                    'defaultOrder'=>'type.id ASC, country.title ASC, t.title ASC',

                    'attributes'=>array(

                        'type.title'=>array(

                            'asc'=>$expr='type.title',

                            'desc'=>$expr.' DESC',

                        ),

                        'country.title'=>array(

                            'asc'=>$expr='country.title',

                            'desc'=>$expr.' DESC',

                        ),

                        '*'

                    )

                ),

                'pagination'=>array(

                    'pageSize'=>Yii::app()->params['pagination']['backoffice'],

                ),

            )

        );

    }

i dono for what $criteria->with=array(‘type’, ‘country’); is used .kindly explain it

the relational query criteria. This is used for fetching related objects in eager loading fashion

http://www.yiiframework.com/doc/api/1.1/CDbCriteria#with-detail

had seen it already ,but no clear idea about it

Hi

Have a look at my extension RelatedSearchBehavior which makes sorting on related tables really easy to do.