Sort by Relational Active Record

Can I sort via a column in a indirect relation?

I have three tables: user, tag, and tagValues. The sort column is in the tag table. user relates to tagValues and tagValues relates to tag.

How can I create a relation in the user model so I can order by the column in the tag table? Thanks.

Here’s what I’m trying

'homePageTag' => array(self::HAS_MANY,'TagValue','userId',



                'order' =>'User_UserTag.sort DESC',


The querying failing because of the .sort as its not calling the tag table. I tried using with() but it still isn’t calling the tag table.