title: Doctrine ORM - Order by a relation field of a relation
body: <p>I've got a problem... I'm doing a loop on a collection, but I want it to be ordered by a target's field.</p>
  <p>The collection I'm looping on :</p>
  <pre><code>/**
   * @ORM\OneToMany(targetEntity=CompoEtapeScenarioCahierCampagne::class, mappedBy=&quot;compoScenarioCahierCampagne&quot;, cascade={&quot;remove&quot;})
   */
  private $compoEtapeScenarioCahierCampagnes;
  </code></pre>
  <p>&quot;etape&quot; is a CompoEtapeScenarioCahierCampagne field :</p>
  <pre><code>/**
   * @ORM\ManyToOne(targetEntity=Etape::class, inversedBy=&quot;compoEtapeScenarioCahierCampagnes&quot;)
   * @ORM\JoinColumn(nullable=false)
   */
  private $etape;
  </code></pre>
  <p>&quot;ordre&quot; is a Etape field :</p>
  <pre><code>/**
   * @ORM\Column(type=&quot;integer&quot;)
   */
  private $ordre;
  </code></pre>
  <p>So when I'm looping on <strong>$compoEtapeScenarioCahierCampagnes</strong>, I want them to be ordered by <strong>$etape.ordre</strong></p>
  <p>Anyway I can do this ? The problem is that I can't do a query because my loop is already in another loop and so on.</p>
  <p><strong>EDIT :</strong></p>
  <p>The loop looks like this :</p>
  <pre><code>{% for etpScnCdrCmp in entity.compoEtapeScenarioCahierCampagnes %}
      {# etpScnCdrCmp is basically $compoEtapeScenarioCahierCampagne #}
      {# But I want those to be orderedBy etpScnCdrCmp.etape.ordre #}
  {% endfor %}
  </code></pre>
  <p><strong>EDIT 2 for more explanation :</strong></p>
  <p>I wanna loop on $compoEtapeScenarioCahierCampagnes as if this ORM annotation could work (where ordre is a Etape's  field) :</p>
  <pre><code>/**
   * @ORM\OneToMany(targetEntity=CompoEtapeScenarioCahierCampagne::class, mappedBy=&quot;compoScenarioCahierCampagne&quot;, cascade={&quot;remove&quot;})
   * @ORM\OrderBy({&quot;etape.ordre&quot; = &quot;ASC&quot;})
   */
  private $compoEtapeScenarioCahierCampagnes;
  </code></pre>