mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
WIP
This commit is contained in:
parent
181b8d5d91
commit
0daeb906f1
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user