private function applySorting(ClassMetadata $metadata, string $className, array $sorting, string $alias): void
    {
        foreach ($sorting as $sort) {
            $customSort = $this->sortingTypeFactory->getCustomSorting($className, $sort['field']);
            if ($customSort) {
                $customSort($this->uniqueNameFactory, $metadata, $this->queryBuilder, $alias, $sort['order']);
            } else {
                $sortingField = $alias . '.' . $sort['field'];
                if ($sort['nullAsHighest'] ?? false) {
                    $expression = 'CASE WHEN ' . $sortingField . ' IS NULL THEN 1 ELSE 0 END';
                    $sortingField = $this->uniqueNameFactory->createAliasName('sorting');
                    $this->queryBuilder->addSelect($expression . ' AS HIDDEN ' . $sortingField);
                }

                $this->queryBuilder->addOrderBy($sortingField, $sort['order']);
            }
        }
    }
private function applySorting(ClassMetadata $metadata, string $className, array $sorting, string $alias): void
    {
        foreach ($sorting as $sort) {
            $customSort = $this->sortingTypeFactory->getCustomSorting($className, $sort['field']);
            if ($customSort) {
                $customSort($this->uniqueNameFactory, $metadata, $this->queryBuilder, $alias, $sort['order']);
            } else {
                $sortingField = $alias . '.' . $sort['field'];
                if ($sort['nullAsHighest'] ?? false) {
                    $expression = 'CASE WHEN ' . $sortingField . ' IS NULL THEN 1 ELSE 0 END';
                    $sortingField = $this->uniqueNameFactory->createAliasName('sorting');
                    $this->queryBuilder->addSelect($expression . ' AS HIDDEN ' . $sortingField);
                }

                $this->queryBuilder->addOrderBy($sortingField, $sort['order']);
            }
        }
    }
private function applySorting ( ClassMetadata $ metadata , string $ className , array $ sorting , string $ alias ) : void { foreach ( $ sorting as $ sort ) { $ customSort = $ this -> sortingTypeFactory -> getCustomSorting ( $ className , $ sort [ 'field' ] ) ; if ( $ customSort ) { $ customSort ( $ this -> uniqueNameFactory , $ metadata , $ this -> queryBuilder , $ alias , $ sort [ 'order' ] ) ; } else { $ sortingField = $ alias . '.' . $ sort [ 'field' ] ; if ( $ sort [ 'nullAsHighest' ] ?? false ) { $ expression = 'CASE WHEN ' . $ sortingField . ' IS NULL THEN 1 ELSE 0 END' ; $ sortingField = $ this -> uniqueNameFactory -> createAliasName ( 'sorting' ) ; $ this -> queryBuilder -> addSelect ( $ expression . ' AS HIDDEN ' . $ sortingField ) ; } $ this -> queryBuilder -> addOrderBy ( $ sortingField , $ sort [ 'order' ] ) ; } } }
Apply sorting to the query builder

@param ClassMetadata $metadata
@param string $className
@param array $sorting
@param string $alias
Apply sorting to the query builder