Order by columns in chain joined relations
<p>In my app I've got such models:
</p>

<pre class="lang-python prettyprint-override"><code>class A(Base):
    id = Column(UUID, primary_key=True)
    name_a = Column(Text)

class B(Base):
    id = Column(UUID, primary_key=True)
    name_b = Column(Text)
    parent_a_id = Column(UUID, ForeignKey(A.id))
    parent_a = relationship(A, lazy='joined')

class C(Base):
    id = Column(UUID, primary_key=True)
    name_c = Column(Text)
    parent_b_id = Column(UUID, ForeignKey(B.id))
    parent_b = relationship(B, lazy='joined')
</code></pre>

<p>When I do:</p>

<pre class="lang-python prettyprint-override"><code>DBSession().query(C).all()
</code></pre>

<p>It works fine - I get all C names with it's B and A name in one LEFT OUTER JOIN query.</p>

<p>But I wonder how to <strong>order by</strong> this query with: <strong>name_a, name_b, name_c</strong>?</p>

<p>I'm trying to do something like:</p>

<pre class="lang-python prettyprint-override"><code>DBSession().query(C).order_by(
    C.parent_b.parent_a.name_a,
    C.parent_b.name_b,
    C.name_c
).all()
</code></pre>

<p>Such code doesn't work. How it can be done with sqlalchemy spirit?</p>