You are here

function _content_sort_items_helper in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6 content.module \_content_sort_items_helper()
  2. 6.2 content.module \_content_sort_items_helper()

Sort function for items order. (copied form element_sort(), which acts on #weight keys)

2 string references to '_content_sort_items_helper'
content_multigroup_node_form_transpose_elements in modules/content_multigroup/content_multigroup.node_form.inc
Transpose element positions in $form_state for the fields in a multigroup.
_content_sort_items in ./content.module
Helper function to sort items in a field according to user drag-n-drop reordering.

File

./content.module, line 962
Allows administrators to associate custom fields to content types.

Code

function _content_sort_items_helper($a, $b) {
  $a_weight = is_array($a) && isset($a['_weight']) ? $a['_weight'] : 0;
  $b_weight = is_array($b) && isset($b['_weight']) ? $b['_weight'] : 0;
  if ($a_weight == $b_weight) {
    return 0;
  }
  return $a_weight < $b_weight ? -1 : 1;
}