Pit Capitain wrote:
> 2008/1/7, Bil Kleb <Bil.Kleb / nasa.gov>:
>> I'm looking for an elegant way to do the following:
>> (...)
> 
> Bil, this makes the test pass:
> 
>   class Array
>     def consolidate
>       Hash[*flatten].sort
>     end
>   end

That certainly is elegant!

Maybe Bil wanted to preserve the monotonicity?

   class Array
     def consolidate
       Hash[*flatten].sort_by {|x,y| y}
     end
   end

   p [ [5,1] , [3,2] ].consolidate # ==> [[5, 1], [3, 2]]

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407