You are here

function _content_sort_items_helper in Content Construction Kit (CCK) 6.2

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

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

1 string reference to '_content_sort_items_helper'
_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 944
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;
}