diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5ed1802f202..9b8232bb188 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6585,7 +6585,7 @@ function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe * or descending output and uses optionally natural case insensitive sorting (which * can be optionally case sensitive as well). * - * @param array $array Array to sort (array of array('key','otherkey1','otherkey2'...)) + * @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) @@ -6604,7 +6604,17 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen if ($sizearray>0) { $temp = array(); - foreach(array_keys($array) as $key) $temp[$key]=$array[$key][$index]; + foreach(array_keys($array) as $key) + { + if (is_object($array[$key])) + { + $temp[$key]=$array[$key]->$index; + } + else + { + $temp[$key]=$array[$key][$index]; + } + } if (! $natsort) { ($order=='asc') ? asort($temp) : arsort($temp);