original_string: public function order($order, $desc = null)
      {
          // Case with comma-separated fields or first argument being an array
          if (is_string($order) && strpos($order, ',') !== false) {
              // Check for multiple
              $order = explode(',', $order);
          }
          if (is_array($order)) {
              if (!is_null($desc)) {
                  throw $this->exception(
                      'If first argument is array, second argument must not be used'
                  );
              }
              foreach (array_reverse($order) as $o) {
                  $this->order($o);
              }
  
              return $this;
          }
  
          // First argument may contain space, to divide field and keyword
          if (is_null($desc) && is_string($order) && strpos($order, ' ') !== false) {
              list($order, $desc) = array_map('trim', explode(' ', trim($order), 2));
          }
  
          if (is_string($order) && strpos($order, '.') !== false) {
              $order = implode('.', $this->bt(explode('.', $order)));
          }
  
          if (is_bool($desc)) {
              $desc = $desc ? 'desc' : '';
          } elseif (strtolower($desc) === 'asc') {
              $desc = '';
          } elseif ($desc && strtolower($desc) != 'desc') {
              throw $this->exception('Incorrect ordering keyword')
                  ->addMoreInfo('order by', $desc);
          }
  
          // TODO:
          /*
          if (isset($this->args['order'][0]) and (
              $this->args['order'][0] === array($order,$desc))) {
          }
           */
          $this->args['order'][] = array($order, $desc);
  
          return $this;
      }
code: public function order($order, $desc = null)
      {
          // Case with comma-separated fields or first argument being an array
          if (is_string($order) && strpos($order, ',') !== false) {
              // Check for multiple
              $order = explode(',', $order);
          }
          if (is_array($order)) {
              if (!is_null($desc)) {
                  throw $this->exception(
                      'If first argument is array, second argument must not be used'
                  );
              }
              foreach (array_reverse($order) as $o) {
                  $this->order($o);
              }
  
              return $this;
          }
  
          // First argument may contain space, to divide field and keyword
          if (is_null($desc) && is_string($order) && strpos($order, ' ') !== false) {
              list($order, $desc) = array_map('trim', explode(' ', trim($order), 2));
          }
  
          if (is_string($order) && strpos($order, '.') !== false) {
              $order = implode('.', $this->bt(explode('.', $order)));
          }
  
          if (is_bool($desc)) {
              $desc = $desc ? 'desc' : '';
          } elseif (strtolower($desc) === 'asc') {
              $desc = '';
          } elseif ($desc && strtolower($desc) != 'desc') {
              throw $this->exception('Incorrect ordering keyword')
                  ->addMoreInfo('order by', $desc);
          }
  
          // TODO:
          /*
          if (isset($this->args['order'][0]) and (
              $this->args['order'][0] === array($order,$desc))) {
          }
           */
          $this->args['order'][] = array($order, $desc);
  
          return $this;
      }
code_tokens: public function order ( $ order , $ desc = null ) { // Case with comma-separated fields or first argument being an array if ( is_string ( $ order ) && strpos ( $ order , ',' ) !== false ) { // Check for multiple $ order = explode ( ',' , $ order ) ; } if ( is_array ( $ order ) ) { if ( ! is_null ( $ desc ) ) { throw $ this -> exception ( 'If first argument is array, second argument must not be used' ) ; } foreach ( array_reverse ( $ order ) as $ o ) { $ this -> order ( $ o ) ; } return $ this ; } // First argument may contain space, to divide field and keyword if ( is_null ( $ desc ) && is_string ( $ order ) && strpos ( $ order , ' ' ) !== false ) { list ( $ order , $ desc ) = array_map ( 'trim' , explode ( ' ' , trim ( $ order ) , 2 ) ) ; } if ( is_string ( $ order ) && strpos ( $ order , '.' ) !== false ) { $ order = implode ( '.' , $ this -> bt ( explode ( '.' , $ order ) ) ) ; } if ( is_bool ( $ desc ) ) { $ desc = $ desc ? 'desc' : '' ; } elseif ( strtolower ( $ desc ) === 'asc' ) { $ desc = '' ; } elseif ( $ desc && strtolower ( $ desc ) != 'desc' ) { throw $ this -> exception ( 'Incorrect ordering keyword' ) -> addMoreInfo ( 'order by' , $ desc ) ; } // TODO: /*
          if (isset($this->args['order'][0]) and (
              $this->args['order'][0] === array($order,$desc))) {
          }
           */ $ this -> args [ 'order' ] [ ] = array ( $ order , $ desc ) ; return $ this ; }
docstring: Orders results by field or Expression. See documentation for full
  list of possible arguments.
  
  $q->order('name');
  $q->order('name desc');
  $q->order('name desc, id asc')
  $q->order('name',true);
  
  @param mixed $order Order by
  @param string|bool $desc  true to sort descending
  
  @return $this
docstring_tokens: Orders results by field or Expression . See documentation for full list of possible arguments .