Sorting CActiveDataProvider by Related Model

Say I have models A, B, and C. Model C contains column ‘createtime’ (int).

Model A and B are in a one-to-many relationship; one A, many B. Model B and C are in a one-to-many relationship; one B, many C. I have a CActiveDataProvider which returns a list of A’s. How do I sort/order the CActiveDataProvider (list of A’s) by the first returned B’s most recent ‘createtime’ from C?