Fix dol_sort_array for objects
This commit is contained in:
parent
bdb467b17a
commit
2d0b3b7b23
@ -6585,7 +6585,7 @@ function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe
|
|||||||
* or descending output and uses optionally natural case insensitive sorting (which
|
* or descending output and uses optionally natural case insensitive sorting (which
|
||||||
* can be optionally case sensitive as well).
|
* 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 string $index Key in array to use for sorting criteria
|
||||||
* @param int $order Sort order ('asc' or 'desc')
|
* @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), 0=use "standard" sort (asort)
|
||||||
@ -6604,7 +6604,17 @@ function dol_sort_array(&$array, $index, $order = 'asc', $natsort = 0, $case_sen
|
|||||||
if ($sizearray>0)
|
if ($sizearray>0)
|
||||||
{
|
{
|
||||||
$temp = array();
|
$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) {
|
if (! $natsort) {
|
||||||
($order=='asc') ? asort($temp) : arsort($temp);
|
($order=='asc') ? asort($temp) : arsort($temp);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user