Table sorting

Last updated on
14 October 2016

This is documentation for Drupal 7, which is no longer supported. 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: