From: John Joyce Date: 2007-06-14T23:34:33+09:00 Subject: Re: sorting arrays within an array by the first object in... On Jun 13, 2007, at 8:45 AM, James Edward Gray II wrote: > On Jun 13, 2007, at 8:39 AM, Mike Dershowitz wrote: > >> I have a parent array of child arrays. >> >> Each child array contains a set of objects. These objects are all >> from >> the same model. >> >> I know that each child array contains at least one object. I want to >> sort on a field in the first object in each child array, and >> arrange the >> child arrays in the parent array according to that field in the first >> object in the child arrays. What's the best way to do this? > > parent_array.sort_by { |child_array| > child_array.first.field_name_here } > > If I understood the question correctly. > > James Edward Gray II > You have to wonder though... If you need the parent sorted, do you also need the child arrays each sorted? Or do you want them as they come in?