function SortArray::sortByKeyString
Same name in other branches
- 9 core/lib/Drupal/Component/Utility/SortArray.php \Drupal\Component\Utility\SortArray::sortByKeyString()
- 10 core/lib/Drupal/Component/Utility/SortArray.php \Drupal\Component\Utility\SortArray::sortByKeyString()
- 11.x core/lib/Drupal/Component/Utility/SortArray.php \Drupal\Component\Utility\SortArray::sortByKeyString()
Sorts a string array item by an arbitrary key.
Parameters
array $a: First item for comparison.
array $b: Second item for comparison.
string $key: The key to use in the comparison.
Return value
int The comparison result for uasort().
4 calls to SortArray::sortByKeyString()
- ConfigDependencyManager::sortGraph in core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigDependencyManager.php - Sorts the dependency graph by reverse weight and alphabetically.
- ConfigDependencyManager::sortGraphByWeight in core/
lib/ Drupal/ Core/ Config/ Entity/ ConfigDependencyManager.php - Sorts the dependency graph by weight and alphabetically.
- SortArray::sortByTitleElement in core/
lib/ Drupal/ Component/ Utility/ SortArray.php - Sorts a structured array by 'title' key (no # prefix).
- SortArray::sortByTitleProperty in core/
lib/ Drupal/ Component/ Utility/ SortArray.php - Sorts a structured array by '#title' property.
File
-
core/
lib/ Drupal/ Component/ Utility/ SortArray.php, line 101
Class
- SortArray
- Provides generic array sorting helper methods.
Namespace
Drupal\Component\UtilityCode
public static function sortByKeyString($a, $b, $key) {
$a_title = is_array($a) && isset($a[$key]) ? $a[$key] : '';
$b_title = is_array($b) && isset($b[$key]) ? $b[$key] : '';
return strnatcasecmp($a_title, $b_title);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.