Fixed minor issue

This commit is contained in:
José González 2022-09-14 17:18:39 +02:00
parent 0daeb906f1
commit 68654804b4
2 changed files with 28 additions and 27 deletions

View File

@ -6217,3 +6217,31 @@ function notify_reporting_console_node()
return $return;
}
/**
* Auxiliar Ordenation function
*
* @param string $sort Direction of sort.
* @param string $sortField Field for perform the sorting.
*
* @return mixed
*/
function arrayOutputSorting($sort, $sortField)
{
return function ($a, $b) use ($sort, $sortField) {
if ($sort === 'up') {
if (is_string($a[$sortField]) === true) {
return strnatcmp($a[$sortField], $b[$sortField]);
} else {
return ($a[$sortField] - $b[$sortField]);
}
} else {
if (is_string($a[$sortField]) === true) {
return strnatcmp($b[$sortField], $a[$sortField]);
} else {
return ($a[$sortField] + $b[$sortField]);
}
}
};
}

View File

@ -1216,33 +1216,6 @@ if ($autosearch) {
$result = array_merge($result, $result_server);
}
/**
* Auxiliar Ordenation function
*
* @param string $sort Direction of sort.
* @param string $sortField Field for perform the sorting.
*/
function arrayOutputSorting($sort, $sortField)
{
return function ($a, $b) use ($sort, $sortField) {
if ($sort === 'up') {
if (is_string($a[$sortField]) === true) {
return strnatcmp($a[$sortField], $b[$sortField]);
} else {
return ($a[$sortField] - $b[$sortField]);
}
} else {
if (is_string($a[$sortField]) === true) {
return strnatcmp($b[$sortField], $a[$sortField]);
} else {
return ($a[$sortField] + $b[$sortField]);
}
}
};
}
usort($result, arrayOutputSorting($sort, $sortField));
metaconsole_restore_db();