You are here

protected function FacetapiWidget::sortCallback in Facet API 7

Same name and namespace in other branches
  1. 6.3 plugins/facetapi/widget.inc \FacetapiWidget::sortCallback()
  2. 7.2 plugins/facetapi/widget.inc \FacetapiWidget::sortCallback()

Applies sort information via the callback in the sort definition.

Each definition in hook_facetapi_sort_info() specifices a "callback", which is the function that returns the sorting information expected by normal uasort() callbacks.

See also

uasort()

File

plugins/facetapi/widget.inc, line 340
Base widget plugin class and helper functions for facet sorting.

Class

FacetapiWidget
Abstract class extended by widget plugins.

Code

protected function sortCallback(array $a, array $b) {
  $return = 0;
  foreach ($this->sorts as $sort) {
    if ($return = $sort['callback']($a, $b)) {
      if (SORT_DESC == $sort['order']) {
        $return *= -1;
      }
      break;
    }
  }
  return $return;
}