src/Sulu/Component/Rest/ListBuilder/Doctrine/DoctrineListBuilder.php
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]);
        }
    }
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]);
        }
    }
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 ] ) ; } }
Assigns ORDER BY clauses to querybuilder.

@param QueryBuilder $queryBuilder
Assigns ORDER BY clauses to querybuilder .