On Sat, Nov 30, 2013 at 4:05 AM, Matthew Kerwin <matthew / kerwin.net.au> wrote:

> Point of order: it's always as fast or faster to iterate once than to sort.

In theory, yes.  In practice since many Array methods are implemented
in C it may actually be faster to sort and then retrieve Array#first
and Array#last.  Measuring is the only way to find out.

But, yes, I prefer to avoid the sort and iterate once because it is
the least invasive thing to do (from a theoretical perspective).  You
just need one traversal to know min and max.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/