$keys = array_keys($waiters);
array_multisort(
$weight, SORT_DESC, SORT_NUMERIC,
$specialties, SORT_ASC, SORT_NUMERIC,
$waiters, $keys
);
$waiters = array_combine($keys, $waiters);
or use uasort
uasort(
$data,
function ($some_data, $another_data) {
$result = 0;
if ($some_data['weight'] > $another_data['weight']) {
$result = -1;
} elseif ($some_data['weight'] < $another_data['weight']) {
$result = 1;
} elseif ($some_data['specialties'] > $another_data['specialties']) {
$result = 2;
} elseif ($some_data['specialties'] < $another_data['specialties']) {
$result = -2;
}
return $result;
}
);
but the uasort performance is significantly worse than array_multisort