gets a single neighboring item

@param Date $slugDate
@param string $direction
@return mixed
181596
private function getNeighbor(Date $slugDate, $direction = 'next')
    {
        if (strcasecmp($direction, 'next') == 0) {
            $activeDate = 'ActiveDate.after';
            $orderBy = 'ActiveDate ASC';
            $slugDate = $slugDate->modify('+1 minute');
        } else {
            $activeDate = 'ActiveDate.before';
            $orderBy = 'ActiveDate DESC';
            $slugDate = $slugDate->modify('-1 minute');
        }

        $nq = new NodeQuery();
        $this->passthruTemplateVariable($nq, 'Elements.in');
        $this->passthruTemplateVariable($nq, 'OutTags.exist');
        $this->passthruTemplateVariable($nq, 'Meta.select');
        $this->passthruTemplateVariable($nq, 'OutTags.select');
        $this->passthruTemplateVariable($nq, 'InTags.select');
        $this->setMetaWhereParams($nq);
        $nq->setParameter($activeDate, $slugDate);
        $nq->setParameter('Status.isActive', true);
        $nq->setLimit(1);
        $nq->isRetrieveTotalRecords(false);
        $nq->setOrderBy($orderBy);

        return $this->RegulatedNodeService->findAll($nq)->getResults();
    }
164064
protected function siblings($direction = '', $parentId = false, $order = 'asc')
    {
        $parentId = ($parentId === false ? $this->parent_id : $parentId);

        /**
         * @var QueryBuilder $query
         */
        $query = $this->where($this->getParentIdColumn(), '=', $parentId);

        $column = $this->getPositionColumn();

        switch ($direction) {
            case static::QUERY_ALL:
                $query->where($column, '<>', $this->position)->orderBy($column, $order);
                break;

            case static::QUERY_PREV_ALL:
                $query->where($column, '<', $this->position)->orderBy($column, $order);
                break;

            case static::QUERY_PREV_ONE:
                $query->where($column, '=', $this->position - 1);
                break;

            case static::QUERY_NEXT_ALL:
                $query->where($column, '>', $this->position)->orderBy($column, $order);
                break;

            case static::QUERY_NEXT_ONE:
                $query->where($column, '=', $this->position + 1);
                break;

            case static::QUERY_NEIGHBORS:
                $query->whereIn($column, [$this->position - 1, $this->position + 1]);
                break;

            case static::QUERY_LAST:
                $query->orderBy($column, 'desc');
                break;
        }

        if (is_int($direction)) {
            $query->where($column, '=', $direction);
        } else if (is_array($direction)) {
            $query->buildWherePosition($this->getPositionColumn(), $direction);
        }

        return $query;
    }
61442
protected function _getUpdateExpression($direction = '+')
    {
        $field = $this->_config['order'];

        return $this->_table->query()->newExpr()
            ->add(new IdentifierExpression($field))
            ->add('1')
            ->setConjunction($direction);
    }
840810
public function adjacentSibling($direction = 1)
    {
        $parent = $this->parent();
        $collection = $parent ? $parent->collection('content', false) : null;
        if ($collection instanceof Collection) {
            return $collection->adjacentSibling($this->path(), $direction);
        }

        return false;
    }
1111185
private function getFirstLastEvent(string $direction): string
    {
        $row    = $this->eventQuery($direction);
        $result = I18N::translate('This information is not available.');

        if ($row) {
            $record = GedcomRecord::getInstance($row->id, $this->tree);

            if ($record && $record->canShow()) {
                $result = $record->formatList();
            } else {
                $result = I18N::translate('This information is private and cannot be shown.');
            }
        }

        return $result;
    }
1247056
public function getOrdered($direction = 'asc')
    {
        $components = $this->enabled();

        uasort($components, function(Component $a, Component $b) use ($direction) {
            if ($a->order == $b->order) {
                return 0;
            }

            if ($direction == 'desc') {
                return $a->order < $b->order ? 1 : -1;
            }

            return $a->order > $b->order ? 1 : -1;
        });

        return $components;
    }
231959
public function orderBy(string $key, string $direction)
    {
        if (str_contains($key, '.')) {
            $fullPath          = explode('.', $key);
            $relationPath      = implode('.', array_slice($fullPath, 0, -1));
            $relationKey       = last($fullPath);
            $result            = array_get($this->relations, $relationPath, ['filters' => [], 'sorts' => []]);
            $result['sorts'][] = new OrderBy($relationKey, $direction);
            array_set($this->relations, $relationPath, $result);
        } else {
            $this->sorts[] = new OrderBy($key, $direction);
        }
        return $this;
    }
704010
public function getRootNodesByLocale($locale, $sortByField = null, $direction = 'asc')
    {
        $rootNodesQueryBuilder = $this->getRootNodesQueryBuilder($sortByField, $direction);
        $alias = $rootNodesQueryBuilder->getRootAliases();
        $rootNodesQueryBuilder->andWhere(sprintf('%s.locale = :locale', $alias[0]))
            ->setParameter(':locale', $locale);

        return $rootNodesQueryBuilder->getQuery()->getResult();
    }
594955
public function getPaginationRequest($direction)
    {
        $pageUrl = $this->getPaginationUrl($direction);
        if (!$pageUrl) {
            return null;
        }

        $newRequest = clone $this->request;
        $newRequest->setEndpoint($pageUrl);

        return $newRequest;
    }
1294824
public function orderBy($orderBy, $direction='asc')
    {
        if($direction == 'desc')
            return $this->model->orderBy($orderBy, 'desc');
        else
            return $this->model->orderBy($orderBy, 'asc');
    }
1255621
public function sortByDimensionValue($direction)
    {
        if ($this->id != '$value') {
            throw new AnalyticsDbException('In order to sort by dimension value, you need to first group by dimension value.');
        }

        $direction = (int)$direction;

        $this->pipeline['$sort'] = ['_id.value' => $direction];


        return $this;
    }
185713
protected function getNullsLastSql($column, $direction)
    {
        $sql = $this->config->get('datatables.nulls_last_sql', '%s %s NULLS LAST');

        return sprintf($sql, $column, $direction);
    }
428041
public function apply($query, $column, $direction = 'asc')
    {
        $direction = $direction === 'desc' ? 'desc' : 'asc';

        if ($query instanceof Model) {
            $query = $query->query();
        }

        $query = $this->applyNullLastQuery($query, $column);

        return $query->orderBy($column, $direction);
    }
740744
public function getCursor($direction)
    {
        if (isset($this->metaData['paging']['cursors'][$direction])) {
            return $this->metaData['paging']['cursors'][$direction];
        }

        return null;
    }
240917
public function getOrdered($direction = 'asc') : array
    {
        $modules = $this->allEnabled();

        uasort($modules, function (Module $a, Module $b) use ($direction) {
            if ($a->order == $b->order) {
                return 0;
            }

            if ($direction == 'desc') {
                return $a->order < $b->order ? 1 : -1;
            }

            return $a->order > $b->order ? 1 : -1;
        });

        return $modules;
    }
481452
@SuppressWarnings("unchecked")
    public static <S extends Storable> OrderedProperty<S> get(ChainedProperty<S> property,
                                                              Direction direction) {
        return (OrderedProperty<S>) cCanonical.put(new OrderedProperty<S>(property, direction));
    }
311404
public function buildSortClosure($propertyPath, $direction)
    {
        $value = function ($data) use ($propertyPath) {
            return $this->propertyAccessor->getValue($data, $propertyPath);
        };

        if ($direction === Util\ColumnSort::ASC) {
            return function ($rowA, $rowB) use ($value) {
                $a = $value($rowA);
                $b = $value($rowB);

                if ($a == $b) {
                    return 0;
                }

                return $a < $b ? -1 : 1;
            };
        } elseif ($direction === Util\ColumnSort::DESC) {
            return function ($rowA, $rowB) use ($value) {
                $a = $value($rowA);
                $b = $value($rowB);

                if ($a == $b) {
                    return 0;
                }

                return $a > $b ? -1 : 1;
            };
        }

        throw new Exception\InvalidArgumentException("Unexpected column sort direction.");
    }