From: Tom Pollard Date: 2006-12-22T01:09:59+09:00 Subject: Re: Tree view hierarchy On Dec 21, 2006, at 9:44 AM, Patrick Spence wrote: > What I need [is] an array that contains something like this: > > [ > ["Smoking|Survey & Feedback"] > ["Depression|Survey & Feedback"] > ["Stress Management|Survey & Feedback"] > ["Weight Management|Exercise|Survey & Feedback"], > ["Weight Management|Healthy Eating|Survey & Feedback"], > ["Weight Management|Managing Emotions|Survey & Feedback"] > ] First, if I was faced with this, I'd create a real tree structure, as Bira showed you, and generate the above list from that. If you need to do anything more than this example, or if there could be multiple levels of parent nodes, then a real tree would be much easier to use. On the other hand, if you really just need that result, and the structure of your menu isn't ever going to have more than one parent level, you could also do something like the following: nodes = [ [ 1, "Smoking", "root" ], ... [13, "Survey & Feedback", "leaf" ] ] root = [] parent = [] leaves = [] nodes.each do |node| idx, title, type = *node case type when 'root' root = [ title ] parent = [] when 'parent' parent = [ title ] when 'leaf' leaves << (root + parent + [title]).join('|') end end At the end, 'leaves' will hold the list you wanted. Cheers, TomP