How do you sort results by the stat column

From this example: (see:

class Post extends CActiveRecord



    public function relations()


        return array(



                              'order'=>'??.createTime DESC',





Which returns the number of comments for a given post ($post->commentCount)

How do you then order the posts based on the comment count? using csort?

i.e. Posts::model->findALL(‘order by comment count’) <- insert real solution here!

Any thoughts on this anyone?

This is not supported (anything related with aggregation is not the strength of AR). You may consider using JOIN and findAllBySql()