Apply Sorting On Attribute

I am new to Yii and unfamiliar with the widgets and CActiveDataProvider etc.

I have a table name t_orders with attribute like created.

My model name is Order.php

Controller name is OrdersController.php

I want to know that how can I apply sorting on the created attribute in ASC or DESC.




$criteria = new CDbCriteria();

$criteria->order = 'created DESC';

$models = Order::model()->findAll($criteria);



$criteria can also be passed to data providers as:




public function search()

{

	$criteria=new CDbCriteria;


	return new CActiveDataProvider(get_class($this), array(

		'criteria'      => $criteria,

		'pagination'    => array(

			'pageSize'  => 10,

			'pageVar'   => 'page',

		),

		'sort'  => array(

			'defaultOrder'  => array(

				'created'   => CSort::SORT_DESC,

			),

		),

	));

}



There’s plenty documentation clearing this out…

What code should i write on front-end (view file)…?