From 0daeb906f100ded397ffd4d33e3fdaa05a4280d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Tue, 6 Sep 2022 14:58:38 +0200 Subject: [PATCH] WIP --- .../operation/agentes/status_monitor.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 7f78680d9a..c39b2cabf3 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -1216,6 +1216,35 @@ 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(); }