Hi -- On Thu, 23 Nov 2006, Darshan.Ishaya wrote: > The Coolest Way: > > def same_elems?(array1, array2) > return false unless array1.length == array2.length > > compare = Proc.new do |x,y| > if (x.class == y.class) You'd probably want to throw in a "and if x.respond_to?('<=>')". > x <=> y > else > x.class.to_s <=> y.class.to_s The problem there is that it can't sort *within* a class that doesn't have <=> (and if it did, it would have sorted it that way :-) So, for example: p [:a,:b].sort(&compare) # => [:a,:b] p [:b,:a].sort(&compare) # => [:b,:a] David -- David A. Black | dblack / wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org