Wednesday, August 3, 2011

[Rails] Re: how-to sorting after group_by ?

In ruby 1.9.2,

...group_by(&:cli).sort

Otherwise, you can't because hashes are unordered by nature. You can
sort the keys and then access the hash using the sorted keys. Or, you
can use ActiveSupport::OrderedHash, and try to figure out how to
initialize it when you have a Hash.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate