original_string: public function orderBy($field, $direction = self::DESC) {
          if (is_array($field)) {
              foreach ($field as $key => $dir) {
                  $this->orderBy($key, $dir);
              }
  
          } else if ($field === 'RAND') {
              $this->_orderBy[] = $this->func('RAND');
  
          } else if ($field instanceof Func) {
              $this->_orderBy[] = $field;
  
          } else {
              $direction = strtolower($direction);
  
              if ($direction != self::ASC && $direction != self::DESC) {
                  throw new InvalidArgumentException(sprintf('Invalid order direction %s for field %s', $direction, $field));
              }
  
              $this->_orderBy[$field] = $direction;
          }
  
          return $this;
      }
code: public function orderBy($field, $direction = self::DESC) {
          if (is_array($field)) {
              foreach ($field as $key => $dir) {
                  $this->orderBy($key, $dir);
              }
  
          } else if ($field === 'RAND') {
              $this->_orderBy[] = $this->func('RAND');
  
          } else if ($field instanceof Func) {
              $this->_orderBy[] = $field;
  
          } else {
              $direction = strtolower($direction);
  
              if ($direction != self::ASC && $direction != self::DESC) {
                  throw new InvalidArgumentException(sprintf('Invalid order direction %s for field %s', $direction, $field));
              }
  
              $this->_orderBy[$field] = $direction;
          }
  
          return $this;
      }
code_tokens: public function orderBy ( $ field , $ direction = self :: DESC ) { if ( is_array ( $ field ) ) { foreach ( $ field as $ key => $ dir ) { $ this -> orderBy ( $ key , $ dir ) ; } } else if ( $ field === 'RAND' ) { $ this -> _orderBy [ ] = $ this -> func ( 'RAND' ) ; } else if ( $ field instanceof Func ) { $ this -> _orderBy [ ] = $ field ; } else { $ direction = strtolower ( $ direction ) ; if ( $ direction != self :: ASC && $ direction != self :: DESC ) { throw new InvalidArgumentException ( sprintf ( 'Invalid order direction %s for field %s' , $ direction , $ field ) ) ; } $ this -> _orderBy [ $ field ] = $ direction ; } return $ this ; }
docstring: Set the fields and direction to order by.
  
  @param string|array $field
  @param string $direction
  @return $this
  @throws \Titon\Db\Exception\InvalidArgumentException
docstring_tokens: Set the fields and direction to order by .