From: Jarrett Green Date: 2008-09-08T16:39:48+09:00 Subject: Hash custom sort? Overriding <=>? Help! This is a pretty ugly hash. The keys are objects. I'm afraid after going down a few paths, it was a bit over my head. Here's the hash: [[#, [#]], [#. I need to sort by 'name'. Though another question remains that would make this all moot. I use: @project_companies = @projects.group_by(&:primary_company) where :primary_company is a relationship situation. I found I can use either the foreign key, (:primary_company_id, which would just give me the id), or the above which gives me the whole enitre object as a key. But is there any in between? Something like: @project_companies = @projects.group_by(&:primary_company.name) If not, how can I create my own sort using <=>??? I found a bit in the rdoc, and well now I'm here. -- Posted via http://www.ruby-forum.com/.