summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/documents_controller.rb3
-rw-r--r--app/views/documents/index.html.erb2
2 files changed, 3 insertions, 2 deletions
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb
index e458d838a..fbd2b4136 100644
--- a/app/controllers/documents_controller.rb
+++ b/app/controllers/documents_controller.rb
@@ -33,7 +33,8 @@ class DocumentsController < ApplicationController
documents = @project.documents.includes(:attachments, :category).to_a
case @sort_by
when 'date'
- @grouped = documents.group_by {|d| d.updated_on.to_date }
+ documents.sort!{|a,b| b.updated_on <=> a.updated_on}
+ @grouped = documents.group_by {|d| d.updated_on.to_date}
when 'title'
@grouped = documents.group_by {|d| d.title.first.upcase}
when 'author'
diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb
index fc4090f55..c0458f8bf 100644
--- a/app/views/documents/index.html.erb
+++ b/app/views/documents/index.html.erb
@@ -18,7 +18,7 @@
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
-<% @grouped.keys.sort.each do |group| %>
+<% @grouped.keys.sort.__send__(@sort_by == 'date' ? :reverse_each : :each) do |group| %>
<h3><%= group %></h3>
<%= render :partial => 'documents/document', :collection => @grouped[group] %>
<% end %>