From: Aaron Haas Date: 2010-11-14T07:18:06+09:00 Subject: Re: help sorting objects by their instance field Nathan Clark wrote in post #961001: > Check the docs for class Array > http://ruby-doc.org/core/classes/Array.html#M002185 > > You can pass a block to array.sort, that tells it what to sort by (in > your case, person.lname). Is this what you mean? I also tried this and I'm getting the following error def print_addresses(&block) @persons.sort_by { |p| persons.lname } @persons.each { |p| yield p } end error... Ruby2.rb:113:in `print_addresses': undefined local variable or method `persons' for # (NameError) from COMP205_8-1Ruby2.rb:222:in `sort_by' from COMP205_8-1Ruby2.rb:113:in `each' from COMP205_8-1Ruby2.rb:113:in `sort_by' from COMP205_8-1Ruby2.rb:113:in `print_addresses' from COMP205_8-1Ruby2.rb:219 -- Posted via http://www.ruby-forum.com/.