8.5.x tablesort.inc tablesort_get_sort($headers)
8.0.x tablesort.inc tablesort_get_sort($headers)
8.1.x tablesort.inc tablesort_get_sort($headers)
8.2.x tablesort.inc tablesort_get_sort($headers)
8.3.x tablesort.inc tablesort_get_sort($headers)
8.4.x tablesort.inc tablesort_get_sort($headers)
8.6.x tablesort.inc tablesort_get_sort($headers)
4.6.x tablesort.inc tablesort_get_sort($headers)
4.7.x tablesort.inc tablesort_get_sort($headers)
5.x tablesort.inc tablesort_get_sort($headers)
6.x tablesort.inc tablesort_get_sort($headers)
7.x tablesort.inc tablesort_get_sort($headers)

Determines the current sort direction.

Parameters

$headers: An array of column headers in the format described in theme_table().

Return value

The current sort direction ("asc" or "desc").

3 calls to tablesort_get_sort()
EntityFieldQuery::tableSort in includes/entity.inc
Enables sortable tables for this query.
TableSort::getSort in includes/tablesort.inc
Determine the current sort direction.
tablesort_init in includes/tablesort.inc
Initialize the table sort context.

File

includes/tablesort.inc, line 239
Functions to aid in the creation of sortable tables.

Code

function tablesort_get_sort($headers) {
  if (isset($_GET['sort'])) {
    return strtolower($_GET['sort']) == 'desc' ? 'desc' : 'asc';
  }
  else {

    // Find out which header is currently being sorted.
    $ts = tablesort_get_order($headers);
    foreach ($headers as $header) {
      if (is_array($header) && isset($header['data']) && $header['data'] == $ts['name'] && isset($header['sort'])) {
        return $header['sort'];
      }
    }
  }
  return 'asc';
}