diff --git a/lib/supplejack/story_item_relation.rb b/lib/supplejack/story_item_relation.rb index c9b1bc6..d08478d 100644 --- a/lib/supplejack/story_item_relation.rb +++ b/lib/supplejack/story_item_relation.rb @@ -54,9 +54,11 @@ def respond_to_missing?(_method, *_args, &_blocks) private def build_items(items) - @items = items.map do |hash| - Supplejack::StoryItem.new(hash.merge(story_id: story.id, api_key: story.api_key)) - end.sort_by(&:position) + story_items = items.map do |item| + Supplejack::StoryItem.new(item.merge(story_id: story.id, api_key: story.api_key)) + end + + @items = story_items.sort_by { |i| i.position.to_i } end end end