Sorting Cutom Column in CGridView

Hi, can i kindly ask for assistance regarding my problem. I have created a custom column in my CGridView that displays custom values.

array(

'header' => $this->t('Likes'),


'name' => 'likes',


'value'=>'$data->getLikes()',


'sortable' => true,

),

Now, the ‘value’ gets its data from a custom function.

The table gets displayed without a problem, however, I would like to sort my table according to the highest value in my custom column, which in my case is the Likes Column.

Thank you!

http://www.yiiframework.com/forum/index.php/topic/24155-cgridview-sorting-of-currency-column-help-requested/

Thanks for the assistance. However, the column i want to sort out wont come from the database. It will be from a custom function. So basically, I have a ‘Likes’ column with (10) rows, all with random numbers (0,10,11,15,99,etc). I want to sort the ‘Likes’ column by its value… Thanks! :slight_smile: