You are here

function filebrowser_sort_table in Filebrowser 5

Does the custom sorting of the table contents based on the sort values (sv) added previously.

1 call to filebrowser_sort_table()
filebrowser_page in ./filebrowser.module
Prints a folder layout
1 string reference to 'filebrowser_sort_table'
filebrowser_page in ./filebrowser.module
Prints a folder layout

File

./filebrowser.module, line 375

Code

function filebrowser_sort_table($a, $b = NULL) {
  static $orderby = 0;
  static $sort = '';

  // Set sorting criteria
  if (!isset($b)) {
    $orderby = (int) $a[0]['sql'] - 1;

    // number of field to sort with
    $sort = $a[1];

    // asc/desc
  }
  elseif (is_array($a) && isset($a[$orderby]) && isset($a[$orderby]['sv'])) {
    if ($a[$orderby]['sv'] == $b[$orderby]['sv']) {
      return 0;
    }
    if ($sort == 'asc') {
      return $a[$orderby]['sv'] > $b[$orderby]['sv'];
    }
    else {
      return $a[$orderby]['sv'] < $b[$orderby]['sv'];
    }
  }
}