src/Query/FluentQuery.php
public function order_by_expression( $expression_alias, $direction = null ) {
		if ( ! in_array( $expression_alias, $this->expressions, true ) ) {
			throw new InvalidColumnException( 'Cannot order by expression alias because the alias has not been used.' );
		}

		if ( is_null( $this->order ) ) {
			$this->order = new Order( $expression_alias, $direction );
		} else {
			$this->order->then( $expression_alias, $direction );
		}

		return $this;
	}
public function order_by_expression( $expression_alias, $direction = null ) {
		if ( ! in_array( $expression_alias, $this->expressions, true ) ) {
			throw new InvalidColumnException( 'Cannot order by expression alias because the alias has not been used.' );
		}

		if ( is_null( $this->order ) ) {
			$this->order = new Order( $expression_alias, $direction );
		} else {
			$this->order->then( $expression_alias, $direction );
		}

		return $this;
	}
Order results by a previously calculated expression.

@param string $expression_alias
@param string $direction

@return $this
@throws InvalidColumnException