original_string: public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
      {
          // we fallback to nb_visits in case columnToSort does not exist
          $columnsToCheck = array($columnToSort, 'nb_visits');
  
          $row = $table->getFirstRow();
  
          foreach ($columnsToCheck as $column) {
              $column = Metric::getActualMetricColumn($table, $column);
  
              if ($row->hasColumn($column)) {
                  // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
                  return $column;
              }
          }
  
          return $columnToSort;
      }
code: public function getPrimaryColumnToSort(DataTable $table, $columnToSort)
      {
          // we fallback to nb_visits in case columnToSort does not exist
          $columnsToCheck = array($columnToSort, 'nb_visits');
  
          $row = $table->getFirstRow();
  
          foreach ($columnsToCheck as $column) {
              $column = Metric::getActualMetricColumn($table, $column);
  
              if ($row->hasColumn($column)) {
                  // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column
                  return $column;
              }
          }
  
          return $columnToSort;
      }
code_tokens: public function getPrimaryColumnToSort ( DataTable $ table , $ columnToSort ) { // we fallback to nb_visits in case columnToSort does not exist $ columnsToCheck = array ( $ columnToSort , 'nb_visits' ) ; $ row = $ table -> getFirstRow ( ) ; foreach ( $ columnsToCheck as $ column ) { $ column = Metric :: getActualMetricColumn ( $ table , $ column ) ; if ( $ row -> hasColumn ( $ column ) ) { // since getActualMetricColumn() returns a default value, we need to make sure it actually has that column return $ column ; } } return $ columnToSort ; }
docstring: Detect the column to be used for sorting
  
  @param DataTable $table
  @param string|int $columnToSort  column name or column id
  @return int
docstring_tokens: Detect the column to be used for sorting