You are here

function _ds_sort_fields in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 includes/field_ui.inc \_ds_sort_fields()
  2. 8.3 includes/field_ui.inc \_ds_sort_fields()
  3. 7.2 includes/ds.field_ui.inc \_ds_sort_fields()
  4. 7 ds.field_ui.inc \_ds_sort_fields()

Utility function to sort a multidimensional array by a value in a sub-array.

Parameters

array $a: The array to sort.

string $subkey: The subkey to sort by.

Return value

array The sorted array.

1 call to _ds_sort_fields()
ds_field_ui_layouts_save in includes/field_ui.inc
Save the layout settings from the 'Manage display' screen.

File

includes/field_ui.inc, line 1543
Field UI functions for Display Suite.

Code

function _ds_sort_fields(array $a, $subkey) {
  $c = [];
  $b = [];
  foreach ($a as $k => $v) {
    if (isset($v[$subkey])) {
      $b[$k] = $v[$subkey];
    }
  }
  asort($b);
  foreach ($b as $key => $val) {
    $c[$key] = $a[$key];
  }
  return $c;
}