Skip to content

Instantly share code, notes, and snippets.

@efatsi
Created January 14, 2013 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efatsi/4531898 to your computer and use it in GitHub Desktop.
Save efatsi/4531898 to your computer and use it in GitHub Desktop.
def self.alphabetized_by_label
initial_hash = all.group_by(&:product_type_name)
initial_hash.each do |key, value|
initial_hash[key] = value.sort{|x,y| x.en_name <=> y.en_name}
end
{}.tap do |final_hash|
initial_hash.keys.sort.each do |key|
final_hash[key] = initial_hash[key]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment