title: Laravel Eloquent: How to order results of related models?
body: <p>I have a model called <strong>School</strong> and it has many <strong>Students</strong> .</p>
  
  <p>Here is the code in my model:</p>
  
  <pre><code>public function students()
  {
      return $this-&gt;hasMany('Student');
  }
  </code></pre>
  
  <p>I am getting all the students with this code in my controller:</p>
  
  <pre><code>$school = School::find($schoolId);
  </code></pre>
  
  <p>and in the view:</p>
  
  <pre><code>@foreach ($school-&gt;students as $student)
  </code></pre>
  
  <p>Now I want to order the <strong>Students</strong> by some field in the <code>students</code> table. How can I do that?</p>