You can define a default order in your model respectively the CActiveDataProvider
. The following snippet sorts by the column SortMeColumn
by default.
public function search()
{
$criteria = new CDbCriteria;
$criteria->compare('ID', $this->ID, true);
$criteria->compare('SortMeColumn', $this->SortMeColumn, true);
return new CActiveDataProvider($this,
array(
'criteria' => $criteria,
'sort' => array(
'defaultOrder' => array(
'SortMeColumn' => CSort::SORT_DESC
),
),
));
}
See CSort for reference.