From c2564a74de6aee3c9fdd9503511fdb9083f587d7 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 9 Dec 2015 16:28:34 +0800 Subject: [PATCH] sort fix --- app/models/project.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index c7dfc90..16047d8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -58,7 +58,7 @@ class Project } end - plugin_datas = datas.sort_for_frontend.collect do |p| + plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index| pd_data = [] fields_to_show.collect do |t| @@ -82,11 +82,12 @@ class Project { "pd_datas" => pd_data, - "type-sort" => (p.project_type.sort_position rescue 1000) + "type-sort" => (p.project_type.sort_position.to_i rescue 1000), + "sort-index" => index } end - plugin_datas = plugin_datas.sort{|k,v| k["type-sort"] <=> v["type-sort"]} + plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]} return [pd_title,plugin_datas] end