Sort in Data Provider

I am trying to load a resultset in a nice single tidy line:


this works just fine. Now I want this to be ordered - is something like the following possible?


Well, you can either overwrite your model’s defaultScope(), add another scope and call it via with() or set CDbCriteria.order within your model’S search() method.

This may work (store MyActiveDataProvider.php in protected/components, change model search() to instantiate MyActiveDataProvider)


class MyActiveDataProvider extends CActiveDataProvider


  public function setSort($value)



    return $this;