From: "Simon Kröger" Date: 2005-12-24T09:01:59+09:00 Subject: Re: How to sort this hash? x1 wrote: > Is it possible to sort the jobs hash below based on values such as > command, start_time and stop_time? > > Ideally, sort_by would be dynamically provided and I would output the > jobs entries based on the value defined for sort_by. This should do: 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 cheers Simon