From adc8c96b1bfb33e33ed799c9b57a09483f2fd758 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Wed, 31 Jul 2019 08:26:17 -0400 Subject: [PATCH] sorting categories on boston pages --- app/views/schools/show.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/schools/show.html.haml b/app/views/schools/show.html.haml index a529c14a..16cc0eb8 100644 --- a/app/views/schools/show.html.haml +++ b/app/views/schools/show.html.haml @@ -8,7 +8,8 @@ %h3 Insufficient Responses %p No data is displayed for this school because of insufficient responses. - elsif @district.name == "Boston" - - grouped = @school_categories.inject({}) do |hash, item| + - sorted_categories = @school_categories.sort { |a, b| "#{a.category.path.first.name} #{a.category.name}" <=> "#{b.category.path.first.name} #{b.category.name}" } + - grouped = sorted_categories.inject({}) do |hash, item| - all = hash[item.category.path.first] || [] - all << item - hash[item.category.path.first] = all @@ -18,7 +19,7 @@ .col-12 %h3= root_category.name .row - = render group.sort { |a, b| a.category.name <=> b.category.name } + = render group - else .row = render @school_categories.sort { |a, b| a.root_index <=> b.root_index }