title: Laravel sort child relationship collection
body: <p>I have the following 3 tables:<br>
  <strong>Movie</strong><br>
  - id<br>
  <strong>Series</strong><br>
  - id<br>
  - status_id<br>
  - movie_id<br>
  <strong>Status</strong><br>
  - id<br>
  - order_number</p>
  
  <p>this is the code on the controller: </p>
  
  <pre><code>$movie = Movie::where('slug', $slug)-&gt;with(['series'])-&gt;first();
  </code></pre>
  
  <p>this is the code for view:</p>
  
  <pre><code>@foreach ($movie-&gt;series as $series)
    {{ $series-&gt;name}}
  @endforeach
  </code></pre>
  
  <p>how to sort <code>$movie-&gt;series</code> based on <code>status-&gt;order_number</code>? if it can be written on the model, so every order is only written once the controller?</p>
  
  <p>is there a code that I can use for example like this:</p>
  
  <pre><code>$movie-&gt;series-&gt;sortBy('status.order_number');
  </code></pre>