You are here

protected function BackendTestBase::facetCompare in Search API 8

Compares two facet filters to determine their order.

Used as a callback for usort() in regressionTests().

Will first compare the counts, ranking facets with higher count first, and then by filter value.

Parameters

array $a: The first facet filter.

array $b: The second facet filter.

Return value

int -1 or 1 if the first filter should, respectively, come before or after the second; 0 if both facet filters are equal.

File

tests/src/Kernel/BackendTestBase.php, line 893

Class

BackendTestBase
Provides a base class for backend tests.

Namespace

Drupal\Tests\search_api\Kernel

Code

protected function facetCompare(array $a, array $b) {
  if ($a['count'] != $b['count']) {
    return $b['count'] - $a['count'];
  }
  return strcmp($a['filter'], $b['filter']);
}