protected function BaseMarkdownPluginManager::sortDefinitions in Markdown 3.0.x
Sorts a definitions array.
This sorts the definitions array first by the weight column, and then by the plugin label, ensuring a stable, deterministic, and testable ordering of plugins.
Parameters
array $definitions: The definitions array to sort.
1 call to BaseMarkdownPluginManager::sortDefinitions()
- BaseMarkdownPluginManager::findDefinitions in src/BaseMarkdownPluginManager.php 
- Finds plugin definitions.
File
- src/BaseMarkdownPluginManager.php, line 126 
Class
Namespace
Drupal\markdownCode
protected function sortDefinitions(array &$definitions) {
  $weight = array_column($definitions, 'weight', 'id');
  $label = array_map(function ($label) {
    return preg_replace("/[^a-z0-9]/", '', strtolower($label));
  }, array_column($definitions, 'label', 'id'));
  array_multisort($weight, SORT_ASC, SORT_NUMERIC, $label, SORT_ASC, SORT_NATURAL, $definitions);
}