/**
* This formats the orderBy array to ignore case differences between the orderBy name and the actually selected name,
* such as for sorting arrays.
*
* @param $selected
* @param $aliases
* @return array
*/
protected function getFormattedOrderBy($selected, $aliases)
{
if (!empty($aliases) && !$this->isWildCardSelection()) {
$orderBy = [];
foreach ($this->orderBy as $attribute => $direction) {
list($alias, $attr) = LdapUtilities::getAliasAndAttribute($attribute);
$orderAttr = MBString::array_search_get_value($attr, $selected);
$orderAttr = $alias ? "{$alias}.{$orderAttr}" : $orderAttr;
$orderBy[$orderAttr] = $direction;
}
} else {
$orderBy = $this->orderBy;
}
return $orderBy;
}