I assume that your result is from a database and you use a CActiveDataProvider
or CSqlDataProvider
. In this case you will have to move the logic for calculateScore
into the DB query somehow. You can add a public property score
to your model class and add this to the select
property of your CDbCriteria
:
$criteria->select = array('*', '... SQL FOR SCORE CALC HERE ... AS score');
Then you will be able to sort by that score
in the sort
definition of your CActiveDataProvider
:
'sort' => array(
'attributes' => array(
// ...
'score',