public function restoreSorting(array $scope = []): void
    {
        $records = $this->_table->find()
            ->select([$this->_table->getPrimaryKey(), $this->getConfig('sortField')])
            ->select($this->getConfig('columnScope'))
            ->order($this->getConfig('defaultOrder'));

        if (!empty($scope)) {
            $records->where($scope);
        }

        $sorts = [];
        foreach ($records as $entity) {
            $individualScope = '';
            foreach ($this->getConfig('columnScope') as $column) {
                $individualScope .= $entity->get($column);
            }

            if (!isset($sorts[$individualScope])) {
                $sorts[$individualScope] = 0;
            }

            $sort = ++$sorts[$individualScope];
            $this->_table->updateAll([
                $this->getConfig('sortField') => $sort,
            ], [
                $this->_table->getPrimaryKey() => $entity->get($this->_table->getPrimaryKey()),
            ]);
        }
    }
public function restoreSorting(array $scope = []): void
    {
        $records = $this->_table->find()
            ->select([$this->_table->getPrimaryKey(), $this->getConfig('sortField')])
            ->select($this->getConfig('columnScope'))
            ->order($this->getConfig('defaultOrder'));

        if (!empty($scope)) {
            $records->where($scope);
        }

        $sorts = [];
        foreach ($records as $entity) {
            $individualScope = '';
            foreach ($this->getConfig('columnScope') as $column) {
                $individualScope .= $entity->get($column);
            }

            if (!isset($sorts[$individualScope])) {
                $sorts[$individualScope] = 0;
            }

            $sort = ++$sorts[$individualScope];
            $this->_table->updateAll([
                $this->getConfig('sortField') => $sort,
            ], [
                $this->_table->getPrimaryKey() => $entity->get($this->_table->getPrimaryKey()),
            ]);
        }
    }
public function restoreSorting ( array $ scope = [ ] ) : void { $ records = $ this -> _table -> find ( ) -> select ( [ $ this -> _table -> getPrimaryKey ( ) , $ this -> getConfig ( 'sortField' ) ] ) -> select ( $ this -> getConfig ( 'columnScope' ) ) -> order ( $ this -> getConfig ( 'defaultOrder' ) ) ; if ( ! empty ( $ scope ) ) { $ records -> where ( $ scope ) ; } $ sorts = [ ] ; foreach ( $ records as $ entity ) { $ individualScope = '' ; foreach ( $ this -> getConfig ( 'columnScope' ) as $ column ) { $ individualScope .= $ entity -> get ( $ column ) ; } if ( ! isset ( $ sorts [ $ individualScope ] ) ) { $ sorts [ $ individualScope ] = 0 ; } $ sort = ++ $ sorts [ $ individualScope ] ; $ this -> _table -> updateAll ( [ $ this -> getConfig ( 'sortField' ) => $ sort , ] , [ $ this -> _table -> getPrimaryKey ( ) => $ entity -> get ( $ this -> _table -> getPrimaryKey ( ) ) , ] ) ; } }
Restores the sorting based on defaultOrder

@return void
Restores the sorting based on defaultOrder