You are here

public function CountWidgetOrderProcessor::sortResults in Facets 8

Orders results and return the new order of results.

Parameters

\Drupal\facets\Result\Result $a: First result which should be compared.

\Drupal\facets\Result\Result $b: Second result which should be compared.

Return value

int -1, 0, or 1 depending which result

Overrides SortProcessorInterface::sortResults

File

src/Plugin/facets/processor/CountWidgetOrderProcessor.php, line 27

Class

CountWidgetOrderProcessor
A processor that orders the results by amount.

Namespace

Drupal\facets\Plugin\facets\processor

Code

public function sortResults(Result $a, Result $b) {
  if ($a
    ->getCount() == $b
    ->getCount()) {
    return 0;
  }
  return $a
    ->getCount() < $b
    ->getCount() ? -1 : 1;
}