$field) { if (is_string($field)) { $fields[$i] = ['field' => $field, 'order' => ZBX_SORT_UP]; } } usort($array, function($a, $b) use ($fields) { foreach ($fields as $field) { $cmp = strnatcasecmp($a[$field['field']], $b[$field['field']]); if ($cmp != 0) { return $cmp * ($field['order'] == ZBX_SORT_UP ? 1 : -1); } } return 0; }); } }