You are here

function _filefield_sources_sort in FileField Sources 8

Same name and namespace in other branches
  1. 6 filefield_sources.module \_filefield_sources_sort()
  2. 7 filefield_sources.module \_filefield_sources_sort()

Custom sort function for ordering sources.

1 string reference to '_filefield_sources_sort'
filefield_sources_info in ./filefield_sources.module
Load hook_filefield_sources_info() data from all modules.

File

./filefield_sources.module, line 678
Extend FileField to allow files from multiple sources.

Code

function _filefield_sources_sort($a, $b) {
  $a = (array) $a + [
    'weight' => 0,
    'label' => '',
  ];
  $b = (array) $b + [
    'weight' => 0,
    'label' => '',
  ];
  return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : strnatcasecmp($a['label'], $b['label']));
}