protected function assignSortFields($queryBuilder)
    {
        // if no sort has been assigned add order by id ASC as default
        if (0 === count($this->sortFields)) {
            $queryBuilder->addOrderBy($this->idField->getSelect(), 'ASC');
        }

        foreach ($this->sortFields as $index => $sortField) {
            $statement = $this->getSelectAs($sortField);
            if (!$this->hasSelectStatement($queryBuilder, $statement)) {
                $queryBuilder->addSelect($this->getSelectAs($sortField, true));
            }

            $queryBuilder->addOrderBy($sortField->getName(), $this->sortOrders[$index]);
        }
    }