public function reorder($middle = true)
    {
        $result = 0;
        \Yii::$app->getDb()->transaction(function () use (&$result, $middle) {
            $list = $this->getQueryInternal()
                ->select($this->owner->primaryKey())
                ->orderBy([$this->sortAttribute => SORT_ASC])
                ->asArray()
                ->all();
            $from = $middle ? count($list) >> 1 : 0;
            foreach ($list as $i => $item) {
                $result += $this->owner->updateAll([$this->sortAttribute => ($i - $from) * $this->step], $item);
            }
        });

        return $result;
    }