private function sortQuery(SelectInterface $query, $name, $suggestion_format) {
    if ($suggestion_format !== SOCIAL_PROFILE_SUGGESTIONS_USERNAME && $this->useFullName()) {
      // Delete percent symbol on the beginning of the phrase for search from
      // the start of field values.
      $name = substr($name, 1);

      $query->addExpression("
    CASE WHEN fn.field_profile_first_name_value LIKE '$name' THEN 0
      WHEN ln.field_profile_last_name_value LIKE '$name' THEN 1
      ELSE 2
    END
  ", 'mention_sort');
      $query->orderBy('mention_sort');
      $query->orderBy('fn.field_profile_first_name_value');
      $query->orderBy('ln.field_profile_last_name_value');
    }

    if ($this->addNickName() === TRUE) {
      $query->orderBy('nn.field_profile_nick_name_value');
    }

    $query->orderBy('uf.name');

    return $query;
  }
private function sortQuery(SelectInterface $query, $name, $suggestion_format) {
    if ($suggestion_format !== SOCIAL_PROFILE_SUGGESTIONS_USERNAME && $this->useFullName()) {
      // Delete percent symbol on the beginning of the phrase for search from
      // the start of field values.
      $name = substr($name, 1);

      $query->addExpression("
    CASE WHEN fn.field_profile_first_name_value LIKE '$name' THEN 0
      WHEN ln.field_profile_last_name_value LIKE '$name' THEN 1
      ELSE 2
    END
  ", 'mention_sort');
      $query->orderBy('mention_sort');
      $query->orderBy('fn.field_profile_first_name_value');
      $query->orderBy('ln.field_profile_last_name_value');
    }

    if ($this->addNickName() === TRUE) {
      $query->orderBy('nn.field_profile_nick_name_value');
    }

    $query->orderBy('uf.name');

    return $query;
  }
private function sortQuery ( SelectInterface $ query , $ name , $ suggestion_format ) { if ( $ suggestion_format !== SOCIAL_PROFILE_SUGGESTIONS_USERNAME && $ this -> useFullName ( ) ) { // Delete percent symbol on the beginning of the phrase for search from // the start of field values. $ name = substr ( $ name , 1 ) ; $ query -> addExpression ( "
    CASE WHEN fn.field_profile_first_name_value LIKE '$name' THEN 0
      WHEN ln.field_profile_last_name_value LIKE '$name' THEN 1
      ELSE 2
    END
  " , 'mention_sort' ) ; $ query -> orderBy ( 'mention_sort' ) ; $ query -> orderBy ( 'fn.field_profile_first_name_value' ) ; $ query -> orderBy ( 'ln.field_profile_last_name_value' ) ; } if ( $ this -> addNickName ( ) === TRUE ) { $ query -> orderBy ( 'nn.field_profile_nick_name_value' ) ; } $ query -> orderBy ( 'uf.name' ) ; return $ query ; }
Sorts the query.

Following the rules:
1. Users whose have first name starting by the given string;
2. Users whose have last name starting by the given string;
3. Users whose have nickname starting by the given string;
4. Users whose have username  starting by the given string;
5. Users containing the string.

@param \Drupal\Core\Database\Query\SelectInterface $query
The select query.
@param string $name
The sanitized string to search for.
@param string $suggestion_format
(optional) The suggestion format.

@return \Drupal\Core\Database\Query\SelectInterface
The select query.
Sorts the query .