function sort_by_length in Lightbox2 8
Same name and namespace in other branches
- 5.2 lightbox2.module \sort_by_length()
- 6 lightbox2.module \sort_by_length()
- 7.2 lightbox2.module \sort_by_length()
- 7 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 1585 - 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\Component\Utility\Unicode::strlen($a) > \Drupal\Component\Utility\Unicode::strlen($b) ? -1 : 1;
}