From: Brian Candler Date: 2009-04-15T18:23:54+09:00 Subject: Re: how to sort my hash Sukhwinder Tambar wrote: > this is my hash .. i want to sort this by 'business_continuity' Actually it's an Array. Both Hash and Array are Enumerable, and Enumerable has sort_by method. work_orders = work_orders.sort_by { |e| e.business_continuity } However, false and true are not comparable, so you need to substitute some values which do. For example, if you want false to sort before true, then: work_orders = work_orders.sort_by { |e| e.business_continuity ? 1 : 0 } If it's really a hash of key=>record, then my_hash.sort_by { |k,v| v.business_continuity ? 1 : 0 } -- Posted via http://www.ruby-forum.com/.