title: Sort a group, depending on key
body: <p>I have a seller list, who are paying service charge. I am listing the service charge according the year. Suppose seller A,C,D paid service charge in 2021, Seller B,E,F in 2022. I want to group them and show in list. Till grouping its okay. The problem I am facing is, The record group is showing 2021 first then 2022, it's showing the group in ascending order. But I want it in descending order.</p>
  <p>Controller</p>
  <pre><code>public function service(){
     $infos = ServiceCharge::all()-&gt;groupBy('year');
     $sellerInfo = Seller_info::orderBy('id','DESC')-&gt;get();
     return view('Backend.pages.account.service',compact('infos','sellerInfo'));
  }
  </code></pre>
  <p>If I use this</p>
  <pre><code>$infos = ServiceCharge::orderBy('year','DESC')-&gt;groupBy('year')-&gt;get();
  dd($infos);
  </code></pre>
  <p>It shows <a href="https://i.stack.imgur.com/o4Ykr.png" rel="nofollow noreferrer">only one value, The first entered value</a></p>
  <p>but without groupBy</p>
  <pre><code>$infos = ServiceCharge::orderBy('year','DESC')-&gt;get();
  dd($infos);
  </code></pre>
  <p>it shows <a href="https://i.stack.imgur.com/9kaEE.png" rel="nofollow noreferrer">all the value</a>. I entered 2 value. This is my <a href="https://i.stack.imgur.com/YzTpm.png" rel="nofollow noreferrer">inserted data formation</a>
  How can I print this in latest year order?</p>