I have this Code to get JSON data from the API:
try {
    // connect to Zabbix-API
    $api = new ZabbixApi($api_url, $username, $password);
 $params = array( 
                           'groupids' => '2',
                           'real_items'        =>TRUE,                    
                            'monitored_items'   =>TRUE, 
                            'search' => array('name' => 'Disk root used p'),                                                                    
                            'selectFunctions'   => 'extend',
                            'output'            => 'extend', 
                            'sortfield'         => 'name'
                            );
    $trends = $api->itemGet($params); // get data from api
  $names = array();
    foreach($trends as $trend)  {       // loop through the returned data
      $names[] = $trend->lastvalue;
    }
} catch(Exception $e) {
    // Exception in ZabbixApi catched
    echo $e->getMessage();
}
The response is:
"result": [
        {
            "itemid": "23298",
            "hostid": "10084",
            "lastvalue": "2552",
            "name": "Disk root used p"        
        },
As you can see I made an array ($names) with only the "lastvalue" in it. Now I'm trying to sort these values by the "hostid". Is this possible and how?
 
     
     
     
    