title: Laravel filter and sort a collection based on conditions
body: <p>I have a collection for example with these details:</p>
  
  <pre><code>collect([
                          [
                              'id'       =&gt; 1,
                              'bankName' =&gt; 'Dare-Schmitt',
                              'pmt'      =&gt; 47068.084449396,
                              'period'   =&gt; 240
                          ],
                          [
                              'id'       =&gt; 2,
                              'bankName' =&gt; 'Dare-Schmitt',
                              'pmt'      =&gt; 45989.430695784,
                              'period'   =&gt; 180
                          ],
                          [
                              'id'       =&gt; 3,
                              'bankName' =&gt; 'Dare-Schmitt',
                              'pmt'      =&gt; 55459.759785392,
                              'period'   =&gt; 240
                          ],
                          [
                              'id'       =&gt; 4,
                              'bankName' =&gt; 'Lorenzo-Platto',
                              'pmt'      =&gt; 37068.084449396,
                              'period'   =&gt; 50
                          ]
                      ]
              );
  </code></pre>
  
  <p>I need to sort and filter them by show only one record for same bankName where the pmt is the highest and just check it on where the period is the same. </p>
  
  <p>So based on the example after filtering and sorting I have to got back this result:</p>
  
  <pre><code>        collect([
                      [
                          'id'       =&gt; 2,
                          'bankName' =&gt; 'Dare-Schmitt',
                          'pmt'      =&gt; 45989.430695784,
                          'period'   =&gt; 180
                      ],
                      [
                          'id'       =&gt; 3,
                          'bankName' =&gt; 'Dare-Schmitt',
                          'pmt'      =&gt; 55459.759785392,
                          'period'   =&gt; 240
                      ],
                      [
                          'id'       =&gt; 4,
                          'bankName' =&gt; 'Lorenzo-Platto',
                          'pmt'      =&gt; 37068.084449396,
                          'period'   =&gt; 50
                      ]
                  ]
          );
  </code></pre>
  
  <p>Any idea how to achive this? I lost a bit :D</p>