From: Adam Akhtar Date: 2008-08-22T11:30:00+09:00 Subject: Re: How to sort this hash? jobs.sort{|a,b|a[1][sort_by] <=> b[1][sort_by]}.each do |k, attributes| puts "------------------" puts attributes["command"] puts attributes["start_time"] puts attributes["stop_time"] end Im a newb but i wouldnt have thought a[1][sort_by] would have worked. I tried accessing this hash in irb in the same way a = {"job" = > {"wage" => 30, "time" => 60}} a[1]["wage"] and got an error NoMethodError: undefined method `[]' for nil:NilClass why does it work???? Can you only access a hash like that within a sort block? -- Posted via http://www.ruby-forum.com/.