You are here

function sort_by_length in Lightbox2 7

Same name and namespace in other branches
  1. 8 lightbox2.module \sort_by_length()
  2. 5.2 lightbox2.module \sort_by_length()
  3. 6 lightbox2.module \sort_by_length()
  4. 7.2 lightbox2.module \sort_by_length()

Helper function to compare the string length of two items. Used when trying to sort an array by value length.

Parameters

$a: String to compare.

$b: String to compare.

Return value

0 if they are the same length, -1 if $a is longer than $b, 1 otherwise.

1 string reference to 'sort_by_length'
lightbox2_add_files in ./lightbox2.module
Provide links to the CSS stylesheet and JS file associated with this module.

File

./lightbox2.module, line 1509
Enables the use of lightbox2 which places images above your current page, not within. This frees you from the constraints of the layout, particularly column widths.

Code

function sort_by_length($a, $b) {
  if ($a == $b) {
    return 0;
  }
  return drupal_strlen($a) > drupal_strlen($b) ? -1 : 1;
}