function styleswitcher_sort in Style Switcher 8.2
Same name and namespace in other branches
- 6.2 styleswitcher.module \styleswitcher_sort()
- 7.2 styleswitcher.module \styleswitcher_sort()
- 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 Drupal\styleswitcher\Plugin\Block\Styleswitcher::build() and Drupal\styleswitcher\Form\StyleswitcherConfigTheme::buildForm().
See also
\Drupal\styleswitcher\Plugin\Block\Styleswitcher::build()
\Drupal\styleswitcher\Form\StyleswitcherConfigTheme::buildForm()
2 string references to 'styleswitcher_sort'
- Styleswitcher::build in src/
Plugin/ Block/ Styleswitcher.php - Builds and returns the renderable array for this block plugin.
- StyleswitcherConfigTheme::buildForm in src/
Form/ StyleswitcherConfigTheme.php - Form constructor.
File
- ./
styleswitcher.module, line 553 - 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];
}