function QueryInterface::sort

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Query/QueryInterface.php \Drupal\Core\Entity\Query\QueryInterface::sort()
  2. 10 core/lib/Drupal/Core/Entity/Query/QueryInterface.php \Drupal\Core\Entity\Query\QueryInterface::sort()
  3. 11.x core/lib/Drupal/Core/Entity/Query/QueryInterface.php \Drupal\Core\Entity\Query\QueryInterface::sort()

Sorts the result set by a given field.

@todo standardize $direction options in https://www.drupal.org/project/drupal/issues/3079258

Parameters

string $field: Name of a field.

string $direction: (optional) The direction to sort. Allowed values are "ASC" and "DESC". Defaults to "ASC".

string|null $langcode: (optional) The language code allows filtering results by specific language. If omitted (NULL), any translation satisfies the condition.

Return value

$this

1 method overrides QueryInterface::sort()
QueryBase::sort in core/lib/Drupal/Core/Entity/Query/QueryBase.php
Sorts the result set by a given field.

File

core/lib/Drupal/Core/Entity/Query/QueryInterface.php, line 189

Class

QueryInterface
Interface for entity queries.

Namespace

Drupal\Core\Entity\Query

Code

public function sort($field, $direction = 'ASC', $langcode = NULL);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.