Implements Drupal\Core\Entity\Query\QueryInterface::tableSort().
Overrides QueryInterface::tableSort
public function tableSort(&$headers) {
// If 'field' is not initialized, the header columns aren't clickable.
foreach ($headers as $key => $header) {
if (is_array($header) && isset($header['specifier'])) {
$headers[$key]['field'] = '';
}
}
$order = tablesort_get_order($headers);
$direction = tablesort_get_sort($headers);
foreach ($headers as $header) {
if (is_array($header) && $header['data'] == $order['name']) {
$this
->sort($header['specifier'], $direction, isset($header['langcode']) ? $header['langcode'] : NULL);
}
}
return $this;
}