return [] unless CAN_SORT_BY.include? sort_by # do this first, so if it's not included # you avoid the overhead of the other processingsort_by = 'group' if sort_by.blank? # .blank? checks for nil? and empty?sorts = array_to_hash(CAN_SORT_BY) # pass the constant created at the top of your model