On Fri, Nov 4, 2011 at 6:49 PM, Wayne Brissette <waynefb / earthlink.net> wrote: > I've put together an array that has a map. I did this so I could do some multi-level sorting of data. For example, if I had a map with: > > Struct.new(:first, :last, :age) > > And let's say I only had some of the ages, so some values were nil. > > Doing a multi-level sort using > > person.sort_by! { |a| [a.last, a.first, a.age]} > > gives me a list sorted correctly by last name, then first, and age?? (maybe, I need to test more) > > If I put the sort_by with a.age first, then I get an error. > > `block in <top (required)>': undefined local variable or method `ball_map' for main:Object (NameError) Where does "ball_map" come from? It's not in the code you've shown. > I'm assuming this is because I'm trying to sort integers and have one with a nil value. So my question really is two-fold. Can I sort based on age if some values are nil? (doesn't look like it), See Bartoz's suggestion. > and second, am I fooling myself into thinking that I'm sorting on a.age when it's not the first sort value? You're not fooling yourself. But the order determines the precedence. The second field is only evaluated if the first fields are equal and so forth. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/