src/QueryModifierBuilder.php
public function orderBy( $expression, $direction = 'ASC' ) {
		$direction = strtoupper( $direction );
		if ( !in_array( $direction, array( 'ASC', 'DESC' ) ) ) {
			throw new InvalidArgumentException( '$direction has to be either ASC or DESC' );
		}

		$this->expressionValidator->validate( $expression,
			ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION
		);

		$this->usageValidator->trackUsedPrefixes( $expression );
		$this->usageValidator->trackUsedVariables( $expression );
		$this->modifiers['ORDER BY'] = $direction . ' (' . $expression . ')';
	}
public function orderBy( $expression, $direction = 'ASC' ) {
		$direction = strtoupper( $direction );
		if ( !in_array( $direction, array( 'ASC', 'DESC' ) ) ) {
			throw new InvalidArgumentException( '$direction has to be either ASC or DESC' );
		}

		$this->expressionValidator->validate( $expression,
			ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION
		);

		$this->usageValidator->trackUsedPrefixes( $expression );
		$this->usageValidator->trackUsedVariables( $expression );
		$this->modifiers['ORDER BY'] = $direction . ' (' . $expression . ')';
	}
public function orderBy ( $ expression , $ direction = 'ASC' ) { $ direction = strtoupper ( $ direction ) ; if ( ! in_array ( $ direction , array ( 'ASC' , 'DESC' ) ) ) { throw new InvalidArgumentException ( '$direction has to be either ASC or DESC' ) ; } $ this -> expressionValidator -> validate ( $ expression , ExpressionValidator :: VALIDATE_VARIABLE | ExpressionValidator :: VALIDATE_FUNCTION ) ; $ this -> usageValidator -> trackUsedPrefixes ( $ expression ) ; $ this -> usageValidator -> trackUsedVariables ( $ expression ) ; $ this -> modifiers [ 'ORDER BY' ] = $ direction . ' (' . $ expression . ')' ; }
Sets the ORDER BY modifier.

@param string $expression
@param string $direction one of ASC or DESC
@throws InvalidArgumentException
Sets the ORDER BY modifier .