mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-04 08:02:22 +01:00
Fix dol_sort_array for objects
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user