function orderBy(array &$array, $sortOrder)
{
usort($array, function ($a, $b) use ($sortOrder) {
$result = '';
$sortOrderArray = explode(',', $sortOrder);
foreach ($sortOrderArray AS $item) {
$itemArray = explode(' ', trim($item));
$field = $itemArray[0];
$sort = !empty($itemArray[1]) ? $itemArray[1] : '';
$mix = [$a, $b];
if (!isset($mix[0][$field]) || !isset($mix[1][$field])) {
continue;
}
if (strtolower($sort) === 'desc') {
$mix = array_reverse($mix);
}
if (is_numeric($mix[0][$field]) && is_numeric($mix[1][$field])) {
$result .= ceil($mix[0][$field] - $mix[1][$field]);
} else {
$result .= strcasecmp($mix[0][$field], $mix[1][$field]);
}
}
return $result;
});
return $array;
}