From 8bd7ddee6b789929f184d16aa00eef67b212ff28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 Jan 2021 13:55:56 +0100 Subject: [PATCH] Clean code --- htdocs/core/lib/functions.lib.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c146f1f9a47..68c8775fd81 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7144,7 +7144,7 @@ function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe * @param array $array Array to sort (array of array('key1'=>val1,'key2'=>val2,'key3'...) or array of objects) * @param string $index Key in array to use for sorting criteria * @param int $order Sort order ('asc' or 'desc') - * @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort) + * @param int $natsort 1=use "natural" sort (natsort) for a search criteria thats is strings or unknown, 0=use "standard" sort (asort) for numbers * @param int $case_sensitive 1=sort is case sensitive, 0=not case sensitive * @param int $keepindex If 0 and index key of array to sort is a numeric, than index will be rewrote. If 1 or index key is not numeric, key for index is kept after sorting. * @return array Sorted array @@ -7170,9 +7170,17 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen } if (!$natsort) { - ($order == 'asc') ? asort($temp) : arsort($temp); + if ($order == 'asc') { + asort($temp); + } else { + arsort($temp); + } } else { - ($case_sensitive) ? natsort($temp) : natcasesort($temp); + if ($case_sensitive) { + natsort($temp); + } else { + natcasesort($temp); // natecasesort is not sensible to case + } if ($order != 'asc') $temp = array_reverse($temp, true); }