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;
});
}