title: Sorting users through relation in laravel
body: <p>i want to sort the users through voornaam(firstname). but im getting the data via a relation.</p>
  
  <p>How do i make my query so that, the relation users are sorted by firstname by alphabet</p>
  
  <p>my function:</p>
  
  <pre><code>public function sortfirstname($id) {
      $ingeschrevenspelers = UserToernooi::with('users')-&gt;where('toernooiid', '=', $id)-&gt;get()-&gt;all();
   //This query ^^
  
  
      $toernooi = Toernooi::findOrFail($id);
  
      dd($ingeschrevenspelers);
      return view('adminfeatures.generatespelerslijst', compact('ingeschrevenspelers', 'toernooi'));
  }
  </code></pre>
  
  <p>What i want to sort
  <a href="https://i.stack.imgur.com/48B05.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/48B05.png" alt="enter image description here"></a></p>
  
  <p>any help is appreciated </p>
  
  <p>thanks in advance</p>