1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-07 23:26:41 +02:00

Merge pull request #3046 from Deltik/fix-3044

Code Climate fix: e_tree_model::multiFieldCmp()
This commit is contained in:
Cameron
2018-02-24 10:40:39 -08:00
committed by GitHub

View File

@@ -3480,17 +3480,9 @@ class e_tree_model extends e_front_model
*/
protected static function multiFieldCmp($row1, $row2, $sort_field, $sort_order = 1)
{
// Multiple sort fields
if (is_array($sort_field))
{
$field = array_shift($sort_field);
}
// One sort field
else
{
$field = $sort_field;
$sort_field = [];
}
if (!is_array($sort_field))
$sort_field = [$sort_field];
$field = array_shift($sort_field);
$cmp = strnatcmp((string) $row1[$field], (string) $row2[$field]);
if ($sort_order === -1 || $sort_order === 1) $cmp *= $sort_order;