You are here

function views_term_hierarchy_sort::hierarchy_sort_cmp in Views term hierarchy 7

File

views/views_term_hierarchy_sort.inc, line 44

Class

views_term_hierarchy_sort

Code

function hierarchy_sort_cmp($a, $b) {
  $a_tid = $a->tid;
  $b_tid = $b->tid;
  if ($a_tid === $b_tid) {
    return 0;
  }
  $a_weight = $a_tid;
  $b_weight = $b_tid;
  if (isset($this->term_weights[$a_tid]) && isset($this->term_weights[$b_tid])) {
    $a_weight = $this->term_weights[$a_tid];
    $b_weight = $this->term_weights[$b_tid];
  }
  if ($a_weight > $b_weight) {
    return 1;
  }
  if ($a_weight < $b_weight) {
    return -1;
  }
  return 0;
}