Standard sorting for a Model or CGridView

Hi to all,

I’d like to sort by ID in descending order by standard, if no other sorting is selected by the user.

I used gii to generate model, controller and crud. Where is the best place to insert a standard sorting?

I tried something like the following in the search-method of the model, but it didn’t work properly:




if (empty($criteria->order)) {

    $criteria->order = 'id DESC';

}



any idea?

bye

use :


return new CActiveDataProvider(

  'criteria'=>[...],

  'sort'=> array('defaultOrder'=>'id DESC')

)

THX, it works!