Module: Katello::SortColumnList
- Defined in:
- app/controllers/katello/sort_column_list.rb
Instance Method Summary collapse
-
#sort_columns(columns, arr) ⇒ Object
columns is a hash with keys being the two pane colunms and value is the arr attribute.
Instance Method Details
#sort_columns(columns, arr) ⇒ Object
columns is a hash with keys being the two pane colunms and value is the arr attribute
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/katello/sort_column_list.rb', line 4 def sort_columns(columns, arr) field = params[:order].split(" ").first if columns.keys.include?(field) # sort based on column name and push any nils to end of array arr.sort! do |a, b| if a.send(columns[field]) && b.send(columns[field]) a.send(columns[field]) <=> b.send(columns[field]) else (a ? -1 : 1) end end arr.reverse! if params[:order].split(" ").last.downcase == "desc" end end |