Skip to content

Instantly share code, notes, and snippets.

@rjmcdonald83
Last active August 29, 2015 13:59
Show Gist options
  • Save rjmcdonald83/51684261bf141df2e6db to your computer and use it in GitHub Desktop.
Save rjmcdonald83/51684261bf141df2e6db to your computer and use it in GitHub Desktop.
Make a pretty sorted list of a counted hash
-if hash_with_count.present?
-# Take a hash formated like so { :a => 2, :b => 4, :c => 6...}, sort it highest to lowest and slice up and iterate over each row.
- hash_with_count.sort_by{|k,v| v}.reverse.each_slice(5).to_a.each do |row|
%ul#tags.list-inline
-row.each do |name, count|
%li
.label.label-success
= name
= count
-else
%p No Hash Present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment