Table sorting

Last updated on
14 October 2016

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Table sorting

To produce a result table which can be sorted by any column, use the TableSort extender and then add the table header. Note that an extender does return a new query object that you need to use from that point on.

$query = $query
  ->extend('TableSort')
  ->orderByHeader($header);

Help improve this page

Page status: No known problems

You can: