ViewsDataHelper::fetchedFieldSort

protected static ViewsDataHelper::fetchedFieldSort($a, $b)

Sort function for fetched fields.

Parameters

array $a: First item for comparison. The compared items should be associative arrays that include a 'group' and a 'title' key.

array $b: Second item for comparison.

Return value

int Returns -1 if $a comes before $b, 1 other way round and 0 if it cannot be decided.

File

core/modules/views/src/ViewsDataHelper.php, line 176

Class

ViewsDataHelper
Defines a helper class for stuff related to views data.

Namespace

Drupal\views

Code

protected static function fetchedFieldSort($a, $b) {
  $a_group = Unicode::strtolower($a['group']);
  $b_group = Unicode::strtolower($b['group']);
  if ($a_group != $b_group) {
    return $a_group < $b_group ? -1 : 1;
  }

  $a_title = Unicode::strtolower($a['title']);
  $b_title = Unicode::strtolower($b['title']);
  if ($a_title != $b_title) {
    return $a_title < $b_title ? -1 : 1;
  }

  return 0;
}
doc_Drupal
2016-10-29 09:55:02
Comments
Leave a Comment

Please login to continue.