/**
  * @inheritdoc
  */
 public function moveToPosition($position)
 {
     if (parent::moveToPosition($position)) {
         return;
     }
     if ($position == 1) {
         // Move as first
         $this->moveToInterval([0, $this->getFirstSort()], $position);
     } elseif ($position == $this->getSortableCount()) {
         // Move as last
         if ($this->isIncreasedLimitReached()) {
             $this->resolveConflict($position);
         } else {
             $this->model->updateAttributes([$this->sortAttribute => $this->getLastSort() + $this->_intervalSize]);
         }
     } else {
         $this->moveToInterval($this->getNewInterval($position), $position);
     }
 }
 /**
  * @inheritdoc
  */
 public function moveToPosition($position)
 {
     if (parent::moveToPosition($position)) {
         return;
     }
     $currentPosition = $this->getSortablePosition();
     if ($position < $currentPosition) {
         // Moving forward
         $oldSortFrom = $position;
         $oldSortTo = $currentPosition - 1;
         $addedValue = 1;
     } else {
         // Moving back
         $oldSortFrom = $currentPosition + 1;
         $oldSortTo = $position;
         $addedValue = -1;
     }
     $models = $this->query->andWhere(['>=', $this->sortAttribute, $oldSortFrom])->andWhere(['<=', $this->sortAttribute, $oldSortTo])->andWhere(['<>', $this->sortAttribute, $currentPosition])->all();
     foreach ($models as $model) {
         $sort = $model->getSort() + $addedValue;
         $model->updateAttributes([$this->sortAttribute => $sort]);
     }
     $this->model->updateAttributes([$this->sortAttribute => $position]);
 }