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.


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

'name' => 'likes',


'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!

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: