fork(1) download
  1. input = [{:name => "Kutty", :score => 2, :some_key => 'value'},
  2. {:name => "Kutty", :score => 4, :some_key => 'value'},
  3. {:name => "Baba", :score => 5, :some_key => 'value'}]
  4.  
  5. output = input.group_by { |x| x[:name] }
  6. .map {|x,y|y.max_by {|x|x[:score]}}
  7.  
  8. puts output
Success #stdin #stdout 0.01s 4760KB
stdin
Standard input is empty
stdout
{:name=>"Kutty", :score=>4, :some_key=>"value"}
{:name=>"Baba", :score=>5, :some_key=>"value"}