You are here

function _file_entity_sort_weight_label in File Entity (fieldable files) 7

Same name and namespace in other branches
  1. 7.3 file_entity.file_api.inc \_file_entity_sort_weight_label()
  2. 7.2 file_entity.file_api.inc \_file_entity_sort_weight_label()

User sort function to sort by weight, then label/name.

2 string references to '_file_entity_sort_weight_label'
file_info_file_types in ./file_entity.file_api.inc
Returns information about file types from hook_file_type_info().
file_info_formatter_types in ./file_entity.file_api.inc
Returns information about file formatters from hook_file_formatter_info().

File

./file_entity.file_api.inc, line 437
API extensions of Drupal core's file.inc.

Code

function _file_entity_sort_weight_label($a, $b) {
  $a_weight = isset($a['weight']) ? $a['weight'] : 0;
  $b_weight = isset($b['weight']) ? $b['weight'] : 0;
  if ($a_weight == $b_weight) {
    $a_label = isset($a['label']) ? $a['label'] : '';
    $b_label = isset($b['label']) ? $b['label'] : '';
    return strcasecmp($a_label, $b_label);
  }
  else {
    return $a_weight < $b_weight ? -1 : 1;
  }
}