Sha256: 0e20906fef1e09603f284a3fb72f44e2ad2d7014f7fa81475bdfe5619dc8cb41
Contents?: true
Size: 640 Bytes
Versions: 44
Compression:
Stored size: 640 Bytes
Contents
module Katello module SortColumnList # columns is a hash with keys being the two pane colunms and value is the arr attribute 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 end end
Version data entries
44 entries across 44 versions & 1 rubygems