original_string: public function order($spec)
      {
          if (!is_array($spec)) {
              $spec = array($spec);
          }
  
          // force 'ASC' or 'DESC' on each order spec, default is ASC.
          foreach ($spec as $val) {
              if ($val instanceof Zend_Db_Expr) {
                  $expr = $val->__toString();
                  if (empty($expr)) {
                      continue;
                  }
                  $this->_parts[self::ORDER][] = $val;
              } else {
                  if (empty($val)) {
                      continue;
                  }
                  $direction = self::SQL_ASC;
                  if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) {
                      $val = trim($matches[1]);
                      $direction = $matches[2];
                  }
                  if (preg_match('/\(.*\)/', $val)) {
                      $val = new Zend_Db_Expr($val);
                  }
                  $this->_parts[self::ORDER][] = array($val, $direction);
              }
          }
  
          return $this;
      }
code: public function order($spec)
      {
          if (!is_array($spec)) {
              $spec = array($spec);
          }
  
          // force 'ASC' or 'DESC' on each order spec, default is ASC.
          foreach ($spec as $val) {
              if ($val instanceof Zend_Db_Expr) {
                  $expr = $val->__toString();
                  if (empty($expr)) {
                      continue;
                  }
                  $this->_parts[self::ORDER][] = $val;
              } else {
                  if (empty($val)) {
                      continue;
                  }
                  $direction = self::SQL_ASC;
                  if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) {
                      $val = trim($matches[1]);
                      $direction = $matches[2];
                  }
                  if (preg_match('/\(.*\)/', $val)) {
                      $val = new Zend_Db_Expr($val);
                  }
                  $this->_parts[self::ORDER][] = array($val, $direction);
              }
          }
  
          return $this;
      }
code_tokens: public function order ( $ spec ) { if ( ! is_array ( $ spec ) ) { $ spec = array ( $ spec ) ; } // force 'ASC' or 'DESC' on each order spec, default is ASC. foreach ( $ spec as $ val ) { if ( $ val instanceof Zend_Db_Expr ) { $ expr = $ val -> __toString ( ) ; if ( empty ( $ expr ) ) { continue ; } $ this -> _parts [ self :: ORDER ] [ ] = $ val ; } else { if ( empty ( $ val ) ) { continue ; } $ direction = self :: SQL_ASC ; if ( preg_match ( '/(.*\W)(' . self :: SQL_ASC . '|' . self :: SQL_DESC . ')\b/si' , $ val , $ matches ) ) { $ val = trim ( $ matches [ 1 ] ) ; $ direction = $ matches [ 2 ] ; } if ( preg_match ( '/\(.*\)/' , $ val ) ) { $ val = new Zend_Db_Expr ( $ val ) ; } $ this -> _parts [ self :: ORDER ] [ ] = array ( $ val , $ direction ) ; } } return $ this ; }
docstring: Adds a row order to the query.
  
  @param mixed $spec The column(s) and direction to order by.
  @return Zend_Db_Select This Zend_Db_Select object.
docstring_tokens: Adds a row order to the query .