Carraydataprovider, Sorting, Relations, Cgridview

I am building a custom search() function for a model to be used in a CGridView. The reason for doing this is that the data in the database is encrypted. I basically use a model::findAll() command to prep the records for the CArrayDataProvider.

$dataProvider=new CArrayDataProvider($found_records,array(












I am building custom search, and that’s fine, its using PHP to look through the attributes in the AR models in the array and filtering accordingly.

Where I’m running into trouble is the sort functionality. The “id” field sorts properly, but I can’t get the relation_id to sort, and I really can’t get the relation name field to sort, since its encrypted in the database. Just saying ASC or DESC won’t work. I need to be able to designate a custom sort at the PHP level. I do searching at the PHP level, since it decrypts in the afterFind() method of the model.

Has anyone done something like this? I’ve searched a few things but really been unable to put this all together.