From: Robert Klemme Date: 2011-03-04T02:35:28+09:00 Subject: Re: Extracting the shortest string from an array On 03.03.2011 16:02, Thorsten Hater wrote: > in Ruby 1.9 this should work: > > arr.sort_by(&:length)[0] Inefficient as it creates a new array. Better do irb(main):001:0> ["qwe", "qwerty"].min_by(&:length) => "qwe" > or more portable/readable (1.8 compatible): > > arr.sort_by{|s| s.length }[0] Inefficient as well (see above). Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/