protected function getUsortReturnValue($attribute, $direction, $a, $b)
{
$compare = [$this->getComparisonValue($a, $attribute), $this->getComparisonValue($b, $attribute)];
// Depending on the direction of the sort, the order of the comparison may need to be reversed.
$compare = $direction == LdapQuery::ORDER['DESC'] ? array_reverse($compare) : $compare;
// This makes sure that objects with non-existent/empty valued attributes go to the end.
// I think this would probably be the desired behavior?
if (empty($compare[0]) && !empty($compare[1])) {
return $direction == LdapQuery::ORDER['ASC'] ? 1 : -1;
} elseif (empty($compare[1]) && !empty($compare[0])) {
return $direction == LdapQuery::ORDER['ASC'] ? -1 : 1;
} else {
return $this->compare(...$compare);
}
}