You are here

function noderelationships_settings_element_sort in Node Relationships 6

Helper function to sort relations by 'weight' attribute.

Based on element_sort(), which acts on '#weight' keys.

1 string reference to 'noderelationships_settings_element_sort'
noderelationships_settings_region_sort in ./noderelationships.inc
Sort back reference regions by weight.

File

./noderelationships.inc, line 255
Common functions for the noderelationships module.

Code

function noderelationships_settings_element_sort($a, $b) {
  $a_weight = is_array($a) && isset($a['weight']) ? $a['weight'] : 0;
  $b_weight = is_array($b) && isset($b['weight']) ? $b['weight'] : 0;
  if ($a_weight == $b_weight) {
    return 0;
  }
  return $a_weight < $b_weight ? -1 : 1;
}