From: Gregory Brown Date: 2007-07-10T22:13:54+09:00 Subject: Re: Beautiful Code : Pity he didn't ask here... On 7/10/07, Wayne E. Seguin wrote: > On Jul 10, 2007, at 08:27 , Christoffer Sawicki wrote: > > Hello. > > > > On 7/10/07, John Carter wrote: > >> count.keys.sort_by{|key| count[key]} > > > > IMHO, the most elegant way to do this is: > > > > hash.sort_by { |k, v| v }.map { |k, v| k } > > > > ...where k = key and v = value. > > > > Cheers, > > Ack, pet peeve. > > hash.sort_by { | key, value | value } .map { | key, value | key } > > If you have to specify "where k = key and v = value" then these > should have been used in your code. > > Always favor readability at the expense of verbosity, both your > future self and whoever else maintains your code will thank you. I find myself always using |k,v|, when used on something hashlike I don't think readability suffers.