From f9be3024b81f2d272ad59649ce37c2ec0e7ac04b Mon Sep 17 00:00:00 2001 From: AMoQu Date: Mon, 16 Nov 2015 13:00:34 +0100 Subject: feat: support sorting of non-numeric indexed parent arrays --- src/SortByFieldExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SortByFieldExtension.php b/src/SortByFieldExtension.php index 8af21f5..144a383 100644 --- a/src/SortByFieldExtension.php +++ b/src/SortByFieldExtension.php @@ -34,7 +34,7 @@ class SortByFieldExtension extends \Twig_Extension { throw new \InvalidArgumentException('Variable passed to the sortByField filter is not an array'); } elseif ($sort_by === null) { throw new Exception('No sort by parameter passed to the sortByField filter'); - } elseif (!self::isSortable($content[0], $sort_by)) { + } elseif (!self::isSortable(current($content), $sort_by)) { throw new Exception('Entries passed to the sortByField filter do not have the field "' . $sort_by . '"'); } else { // Unfortunately have to suppress warnings here due to __get function -- cgit v1.2.3