You are here

function tablesort_get_sort in Drupal 5

Same name and namespace in other branches
  1. 8 core/includes/tablesort.inc \tablesort_get_sort()
  2. 4 includes/tablesort.inc \tablesort_get_sort()
  3. 6 includes/tablesort.inc \tablesort_get_sort()
  4. 7 includes/tablesort.inc \tablesort_get_sort()

Determine 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").

1 call to tablesort_get_sort()
tablesort_init in includes/tablesort.inc
Initialize the table sort context.

File

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

Code

function tablesort_get_sort($headers) {
  if (isset($_GET['sort'])) {
    return $_GET['sort'] == 'desc' ? 'desc' : 'asc';
  }
  else {
    foreach ($headers as $header) {
      if (is_array($header) && array_key_exists('sort', $header)) {
        return $header['sort'];
      }
    }
  }
  return 'asc';
}