From: Aldric Giacomoni Date: 2009-12-11T01:39:05+09:00 Subject: Re: Fill gaps in Array of Hashes Joao Silva wrote: > Yep, i understand, but it returns wrong value (and not sorted by date > ;-(): Try this then. ("2009-11-11".to_date.."2010-01-01".to_date).each do |date| exists = result.find { |x| x[:date] == date.to_s } next if exists result << { :positive => "0", :neutral => "0", :total => "0", :date => date.to_s, :negative => "0" } end array.sort! { |a, b| a[:date].to_date <=> b[:date].to_date } Just a teeny tiny little "to_s". And sorting an array is a simple matter of looking up the sort method in the rdoc (which IS your best friend). -- Posted via http://www.ruby-forum.com/.