You are here

function _breakpoints_sort_by_weight in Breakpoints 7

Sort breakpoints by weight.

1 call to _breakpoints_sort_by_weight()
_breakpoints_sort_by_weight_array in ./breakpoints.module
Sort breakpoints by weight.
1 string reference to '_breakpoints_sort_by_weight'
breakpoints_breakpoint_load_all in ./breakpoints.module
Load all breakpoints.

File

./breakpoints.module, line 323
Breakpoints @todo: provide button to reload breakpoints from theme

Code

function _breakpoints_sort_by_weight($a, $b) {
  if (isset($a->weight) && isset($b->weight)) {
    if ($a->weight == $b->weight) {
      if (isset($a->source_type) && $a->source_type == BREAKPOINTS_SOURCE_TYPE_CUSTOM) {
        return -1;
      }
      if (isset($b->source_type) && $b->source_type == BREAKPOINTS_SOURCE_TYPE_CUSTOM) {
        return 1;
      }
      return 0;
    }
    return $a->weight < $b->weight ? -1 : 1;
  }
  return 0;
}