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 }
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en