/** * Sorts LDAP search results. * * @param array $models * * @return Collection */ protected function processSort(array $models = []) { $field = $this->builder->getSortByField(); $flags = $this->builder->getSortByFlags(); $direction = $this->builder->getSortByDirection(); $desc = $direction === 'desc' ? true : false; return $this->newCollection($models)->sortBy(function (Model $model) use($field) { return $model->getAttribute($field, 0); }, $flags, $desc); }