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 :)


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




 &#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(),



                    'name'   =&gt; 'E_Id',

                    'header' =&gt; 'Email Id'



                    'name'   =&gt; 'Receiver',

                    'header' =&gt; 'Receiver'





In my code I use this

    public function search()


        $criteria=new CDbCriteria;








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

        return new CActiveDataProvider(





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




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




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











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

had seen it already ,but no clear idea about it


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