You are here

public function Report::setSort in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 src/Report.php \Drupal\forena\Report::setSort()
1 call to Report::setSort()
Report::sort in src/Report.php
Sort the current data context if it is an array.

File

src/Report.php, line 640
Basic report provider. Controls the rendering of the report.

Class

Report

Namespace

Drupal\forena

Code

public function setSort($sort, $compare_type = '') {
  if (!$compare_type) {
    if (defined(SORT_NATURAL)) {
      $compare_type = SORT_NATURAL;
    }
  }
  else {
    if (is_string($compare_type)) {
      if (defined($compare_type)) {
        $compare_type = constant($compare_type);
      }
      else {
        $compare_type = SORT_REGULAR;
      }
    }
  }
  $this->compareType = $compare_type;

  // Assume an array of sort algorithms
  if (is_array($sort)) {
    $this->sortCriteria = $sort;
  }
  else {
    $this->sortCriteria = (array) $sort;
  }
}