function twig_sort_filter in Translation template extractor 7.3
Same name and namespace in other branches
- 6.3 vendor/Twig/Extension/Core.php \twig_sort_filter()
Sorts an array.
Parameters
array|Traversable $array:
Return value
array
1 string reference to 'twig_sort_filter'
- Twig_Extension_Core::getFilters in vendor/
Twig/ Extension/ Core.php - Returns a list of filters to add to the existing list.
File
- vendor/
Twig/ Extension/ Core.php, line 944
Code
function twig_sort_filter($array) {
if ($array instanceof Traversable) {
$array = iterator_to_array($array);
}
elseif (!is_array($array)) {
throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
}
asort($array);
return $array;
}