original_string: public function sortColumnsByOrder()
      {
          $columns = $this->_columns;
          foreach ($this->getColumnsOrder() as $columnId => $after) {
              if ($after[0] === '-') {
                  $before = substr($after, 1);
                  $after = null;
              } else {
                  $before = null;
              }
              if ($after !== null && isset($columns[$after])) {
                  $currentPosition = array_search($columnId, array_keys($columns));
                  $value = array_splice($columns, $currentPosition, 1);
  
                  $destPosition = array_search($after, array_keys($columns)) + 1;
                  $columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
              } elseif ($before !== null && $columns[$before]) {
                  $currentPosition = array_search($columnId, array_keys($columns));
                  $value = array_splice($columns, $currentPosition, 1);
  
                  $destPosition = array_search($before, array_keys($columns));
                  $columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
              }
          }
  
          $this->_columns = $columns;
  
          end($this->_columns);
          $this->_lastColumnId = key($this->_columns);
          return $this;
      }
code: public function sortColumnsByOrder()
      {
          $columns = $this->_columns;
          foreach ($this->getColumnsOrder() as $columnId => $after) {
              if ($after[0] === '-') {
                  $before = substr($after, 1);
                  $after = null;
              } else {
                  $before = null;
              }
              if ($after !== null && isset($columns[$after])) {
                  $currentPosition = array_search($columnId, array_keys($columns));
                  $value = array_splice($columns, $currentPosition, 1);
  
                  $destPosition = array_search($after, array_keys($columns)) + 1;
                  $columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
              } elseif ($before !== null && $columns[$before]) {
                  $currentPosition = array_search($columnId, array_keys($columns));
                  $value = array_splice($columns, $currentPosition, 1);
  
                  $destPosition = array_search($before, array_keys($columns));
                  $columns = array_slice($columns, 0, $destPosition) + $value + array_slice($columns, $destPosition);
              }
          }
  
          $this->_columns = $columns;
  
          end($this->_columns);
          $this->_lastColumnId = key($this->_columns);
          return $this;
      }
code_tokens: public function sortColumnsByOrder ( ) { $ columns = $ this -> _columns ; foreach ( $ this -> getColumnsOrder ( ) as $ columnId => $ after ) { if ( $ after [ 0 ] === '-' ) { $ before = substr ( $ after , 1 ) ; $ after = null ; } else { $ before = null ; } if ( $ after !== null && isset ( $ columns [ $ after ] ) ) { $ currentPosition = array_search ( $ columnId , array_keys ( $ columns ) ) ; $ value = array_splice ( $ columns , $ currentPosition , 1 ) ; $ destPosition = array_search ( $ after , array_keys ( $ columns ) ) + 1 ; $ columns = array_slice ( $ columns , 0 , $ destPosition ) + $ value + array_slice ( $ columns , $ destPosition ) ; } elseif ( $ before !== null && $ columns [ $ before ] ) { $ currentPosition = array_search ( $ columnId , array_keys ( $ columns ) ) ; $ value = array_splice ( $ columns , $ currentPosition , 1 ) ; $ destPosition = array_search ( $ before , array_keys ( $ columns ) ) ; $ columns = array_slice ( $ columns , 0 , $ destPosition ) + $ value + array_slice ( $ columns , $ destPosition ) ; } } $ this -> _columns = $ columns ; end ( $ this -> _columns ) ; $ this -> _lastColumnId = key ( $ this -> _columns ) ; return $ this ; }
docstring: Sort columns by predefined order
  
  @return Mage_Adminhtml_Block_Widget_Grid
docstring_tokens: Sort columns by predefined order