protected function orderByPending()
    {
        $properties = $this->pending['orderBy'];
        uasort($this->data, function($a, $b) use ($properties)
        {
            foreach ($properties as $column => $direction)
            {
                if (is_int($column))
                {
                    $column    = $direction;
                    $direction = SORT_ASC;
                }
                $collapse = function($node, $props)
                {
                    if (is_array($props))
                    {
                        foreach ($props as $prop)
                        {
                            $node = (!isset($node->$prop)) ? null : $node->$prop;
                        }
                        return $node;
                    }
                    else
                    {
                        return (!isset($node->$props)) ? null : $node->$props;
                    }
                };
                $aProp = $collapse($a, $column);
                $bProp = $collapse($b, $column);

                if ($aProp != $bProp)
                {
                    return ($direction == SORT_ASC) ? strnatcasecmp($aProp, $bProp) : strnatcasecmp($bProp, $aProp);
                }
            }
            return FALSE;
        });
    }
protected function orderByPending()
    {
        $properties = $this->pending['orderBy'];
        uasort($this->data, function($a, $b) use ($properties)
        {
            foreach ($properties as $column => $direction)
            {
                if (is_int($column))
                {
                    $column    = $direction;
                    $direction = SORT_ASC;
                }
                $collapse = function($node, $props)
                {
                    if (is_array($props))
                    {
                        foreach ($props as $prop)
                        {
                            $node = (!isset($node->$prop)) ? null : $node->$prop;
                        }
                        return $node;
                    }
                    else
                    {
                        return (!isset($node->$props)) ? null : $node->$props;
                    }
                };
                $aProp = $collapse($a, $column);
                $bProp = $collapse($b, $column);

                if ($aProp != $bProp)
                {
                    return ($direction == SORT_ASC) ? strnatcasecmp($aProp, $bProp) : strnatcasecmp($bProp, $aProp);
                }
            }
            return FALSE;
        });
    }
protected function orderByPending ( ) { $ properties = $ this -> pending [ 'orderBy' ] ; uasort ( $ this -> data , function ( $ a , $ b ) use ( $ properties ) { foreach ( $ properties as $ column => $ direction ) { if ( is_int ( $ column ) ) { $ column = $ direction ; $ direction = SORT_ASC ; } $ collapse = function ( $ node , $ props ) { if ( is_array ( $ props ) ) { foreach ( $ props as $ prop ) { $ node = ( ! isset ( $ node -> $ prop ) ) ? null : $ node -> $ prop ; } return $ node ; } else { return ( ! isset ( $ node -> $ props ) ) ? null : $ node -> $ props ; } } ; $ aProp = $ collapse ( $ a , $ column ) ; $ bProp = $ collapse ( $ b , $ column ) ; if ( $ aProp != $ bProp ) { return ( $ direction == SORT_ASC ) ? strnatcasecmp ( $ aProp , $ bProp ) : strnatcasecmp ( $ bProp , $ aProp ) ; } } return FALSE ; } ) ; }
Sort an array of objects by more than one field.
@
@link http://blog.amnuts.com/2011/04/08/sorting-an-array-of-objects-by-one-or-more-object-property/ It's not mine algorithm
Sort an array of objects by more than one field .