function QueryBase::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
Overrides QueryInterface::sort
1 call to QueryBase::sort()
- QueryBase::tableSort in core/lib/ Drupal/ Core/ Entity/ Query/ QueryBase.php 
- Enables sortable tables for this query.
File
- 
              core/lib/ Drupal/ Core/ Entity/ Query/ QueryBase.php, line 237 
Class
- QueryBase
- The base entity query class.
Namespace
Drupal\Core\Entity\QueryCode
public function sort($field, $direction = 'ASC', $langcode = NULL) {
  $this->sort[] = [
    'field' => $field,
    'direction' => strtoupper($direction),
    'langcode' => $langcode,
  ];
  return $this;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
