From: "Florian Groß" Date: 2005-12-24T10:23:48+09:00 Subject: Re: How to sort this hash? Jeff Cohen wrote: >>jobs.sort{|a,b|a[1][sort_by] <=> b[1][sort_by]}.each do |k, attributes| > I just can't quite understand the [sort_by] usage here...? It looks up the value in the hash from a[1] (a[0] is "2231" / "1131" / "231" for the sample data) that represents to the key identified by sort_by. So if sort_by is "command" it will sort the jobs by the value corresponding to their "command" key. Which is "test_a.bash" for job "2231", "test_b.bash" for job "1131", "test_c.bash" for job "231" and so on... -- http://flgr.0x42.net/