diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb index 1ddd800a..849fe226 100644 --- a/lib/liquid/standardfilters.rb +++ b/lib/liquid/standardfilters.rb @@ -98,7 +98,7 @@ module Liquid # Sort elements of the array # provide optional property with which to sort an array of hashes or drops def sort(input, property = nil) - ary = InputIterator.new(input).to_a + ary = InputIterator.new(input) if property.nil? ary.sort elsif ary.first.respond_to?('[]'.freeze) and !ary.first[property].nil? diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index 9486ff6f..7b417ae6 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -7,6 +7,8 @@ class Filters end class TestThing + attr_reader :foo + def initialize @foo = 0 end @@ -149,7 +151,8 @@ class StandardFiltersTest < Test::Unit::TestCase def test_sort_calls_to_liquid t = TestThing.new - assert_template_result "woot: 1", '{{ foo | sort: "whatever" }}', "foo" => [t] + Liquid::Template.parse('{{ foo | sort: "whatever" }}').render("foo" => [t]) + assert t.foo > 0 end def test_map_over_proc