From: Intransition Date: 2012-12-01T03:33:27+09:00 Subject: Re: Ordered Hash (v. 1.8) ------=_Part_266_9942614.1354297617815 Content-Type: multipart/alternative; boundary="----=_Part_267_4443266.1354297617815" ------=_Part_267_4443266.1354297617815 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Thursday, November 29, 2012 8:46:48 PM UTC-5, Doug Jolley wrote: > > I am running Ruby v. 1.8.7 and I have installed the orderedhash gem. I > know that the purpose of orderedhash is to preserve the order of > creation. However, what I'd really like to do is, after the hash has > been created, sort it on the key in a manner similar to the way that I > would sort an array with the sort!() method and then preserve the sorted > order. Any ideas on how I might accomplish that feat? Thanks for any > input. > You can use Hashery's Disctionary class. $ gem install hashery Then code: require 'hashery/dictionary' dict = Hashery::Dictionary.new_by{ |k,v| k } ------=_Part_267_4443266.1354297617815 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On Thursday, November 29, 2012 8:46:48 PM UTC-5, Doug Jolley wrote:
I am running Ruby v. 1.8.7 and I have installed the orderedhash gem.  I
know that the purpose of orderedhash is to preserve the order of
creation.  However, what I'd really like to do is, after the hash has
been created, sort it on the key in a manner similar to the way that I
would sort an array with the sort!() method and then preserve the sorted
order.  Any ideas on how I might accomplish that feat?  Thanks for any
input.

You can use Hashery's Disctionary class.

  $ gem install hashery

Then code:

  require 'hashery/dictionary'

  dict = Hashery::Dictionary.new_by{ |k,v| k }

 
------=_Part_267_4443266.1354297617815-- ------=_Part_266_9942614.1354297617815--