public function IngredientUnitUtility::sortUnitsByName in Recipe 8.2
Sorts an array of units by the name element.
Parameters
array $units: An array containing a 'name' element.
Return value
array The sorted array of units.
File
- modules/
ingredient/ src/ Utility/ IngredientUnitUtility.php, line 71
Class
- IngredientUnitUtility
- Provides the ingredient.unit service.
Namespace
Drupal\ingredient\UtilityCode
public function sortUnitsByName(array $units) {
uasort($units, function ($a, $b) {
return strcmp($a['name'], $b['name']);
});
return $units;
}