function _block_compare

7.x block.admin.inc _block_compare($a, $b)
6.x block.admin.inc _block_compare($a, $b)

Helper function for sorting blocks on admin/build/block.

Active blocks are sorted by region, then by weight. Disabled blocks are sorted by name.

1 string reference to '_block_compare'
block_admin_display in drupal-6.x/modules/block/block.admin.inc
Menu callback for admin/build/block.

File

drupal-6.x/modules/block/block.admin.inc, line 115
Admin page callbacks for the block module.

Code

function _block_compare($a, $b) {
  global $theme_key;
  static $regions;

  // We need the region list to correctly order by region.
  if (!isset($regions)) {
    $regions = array_flip(array_keys(system_region_list($theme_key)));
    $regions[BLOCK_REGION_NONE] = count($regions);
  }

  // Separate enabled from disabled.
  $status = $b['status'] - $a['status'];
  if ($status) {
    return $status;
  }
  // Sort by region (in the order defined by theme .info file).
  if ((!empty($a['region']) && !empty($b['region'])) && ($place = ($regions[$a['region']] - $regions[$b['region']]))) {
    return $place;
  }
  // Sort by weight.
  $weight = $a['weight'] - $b['weight'];
  if ($weight) {
    return $weight;
  }
  // Sort by title.
  return strcmp($a['info'], $b['info']);
}