title: PHP find object has highest value in array
body: <p>I'm looking for shortest way to find the object which contains highest <code>sort</code> value.</p>
  
  <pre><code>array(5) {
    [0]=&gt;
    object(stdClass)#212 (3) {
      ["id"]=&gt;
      int(1)
      ["display_name"]=&gt;
      string(8) "Activate"
      ["sort"]=&gt;
      int(1)
    }
    [1]=&gt;
    object(stdClass)#213 (3) {
      ["id"]=&gt;
      int(2)
      ["display_name"]=&gt;
      string(7) "Cutting"
      ["sort"]=&gt;
      int(2)
    }
    [2]=&gt;
    object(stdClass)#214 (3) {
      ["id"]=&gt;
      int(3)
      ["display_name"]=&gt;
      string(6) "Sewing"
      ["sort"]=&gt;
      int(3)
    }
    [3]=&gt;
    object(stdClass)#215 (3) {
      ["id"]=&gt;
      int(4)
      ["display_name"]=&gt;
      string(9) "Finishing"
      ["sort"]=&gt;
      int(4)
    }
    [4]=&gt;
    object(stdClass)#216 (3) {
      ["id"]=&gt;
      int(5)
      ["display_name"]=&gt;
      string(10) "Deactivate"
      ["sort"]=&gt;
      int(5)
    }
  }
  </code></pre>
  
  <p>Below is my practicing but I think it is complex and long of code. </p>
  
  <pre><code>// $gateways is the array contains a list of objects.
  
  // find max sort value in array first
  $max = max( array_map(function( $row ){ return $row-&gt;sort; }, $gateways) );
  
  // then find in array object with sort value is equal to $max value
  $filter = array_filter($gateways, function($row) use ($max){ 
    return $max == $row-&gt;sort;
  });
  
  if(count($filter)){
    $finalResult = array_shift($filter);
  }
  </code></pre>
  
  <p>Is there shorter way to do this like <code>reduce</code> in Javascript?</p>
  
  <p>Thanks.</p>