From: Francis Cianfrocca Date: 2006-08-13T16:48:02+09:00 Subject: Re: A use case for an ordered hash On 8/13/06, Hal Fulton wrote: > actions = { /abcd/ => lambda { do_this }, > /xyz/ => lambda { do_that }, > /abc/ => lambda { other }} > actions.keys.sort {|a,b| b.to_s <=> a.to_s}.each {|k| if k =~ your_string actions[k].call break end } A more-greedy regex sorts lexicographically behind a head-matching less-greedy one.