Skip to content

Instantly share code, notes, and snippets.

@axgle
Created October 25, 2009 14:14
Show Gist options
  • Save axgle/218077 to your computer and use it in GitHub Desktop.
Save axgle/218077 to your computer and use it in GitHub Desktop.
puts DATA.read.scan(/\w+/).inject({}){|s,w|
w.downcase!
s[w]||=0
s[w]+=1
s
}.sort_by{|k,v|v}.reverse.map{|k,v|"#{k}: #{v}"}
__END__
<<word counter with ruby>>
counter is great
using ruby for counter
Is it great?
any more counter?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment