Skip to content

Instantly share code, notes, and snippets.

@liuweiathust
Created December 24, 2011 07:20
Show Gist options
  • Save liuweiathust/1516675 to your computer and use it in GitHub Desktop.
Save liuweiathust/1516675 to your computer and use it in GitHub Desktop.
read each line's second field, and sort by frequency, return top 10 frequency records
ARGF.readlines.inject(Hash.new(0)){ |h,l| h[l.chomp.split[1]] += 1;h}.sort.last(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment