You are here

function styleswitcher_sort in Style Switcher 6.2

Same name and namespace in other branches
  1. 8.2 styleswitcher.module \styleswitcher_sort()
  2. 7.2 styleswitcher.module \styleswitcher_sort()
  3. 3.0.x styleswitcher.module \styleswitcher_sort()

Sorts styles by weight and index.

This function first compares style weights, and then - if weights are equal - style index numbers.

The compared items (function parameters) should be associative arrays that include a 'weight' and an '_i' elements.

Callback for uasort() within styleswitcher_block_view() and styleswitcher_admin().

See also

styleswitcher_admin()

styleswitcher_block_view()

2 string references to 'styleswitcher_sort'
styleswitcher_block_view in ./styleswitcher.module
Returns a renderable view of a block.
styleswitcher_config_theme in ./styleswitcher.admin.inc
Page callback: Constructs a form for a theme-specific styles settings.

File

./styleswitcher.module, line 749
Module's hooks implementations and helper functions.

Code

function styleswitcher_sort(array $a, array $b) {
  $property = $a['weight'] != $b['weight'] ? 'weight' : '_i';
  return $a[$property] - $b[$property];
}