From: hurcan solter Date: 2007-03-18T09:55:04+09:00 Subject: Re: mixin classes (continuning from the last post) On Mar 18, 2:00 am, Gary Wright wrote: > It looks like REXML already provides the two > iterators you need to satisfy TSort. Try this: > > require 'rexml/document' > require 'tsort' > > class REXML::Element > include TSort > def tsort_each_node(&block) > each_recursive(&block) > end > def tsort_each_child(node, &block) > node.each_child(&block) if node.respond_to?(:each_child) > end > end > > doc = REXML::Document.new < > Text, text, text > > EOS > p doc.tsort > > Gary Wright well my sorting criteria something different from that.Consider this; EntityIdentifierStruct depends on FederateIdentifierStruct and FederateIdentifierStruct depends on none (primitives not important) and i also have to extract that denpendency information from child node attributes so one to one comparison wont work. So I have to compose a dependency graph first and keep it somewhere (I am thinking the element itself ,so the need for instance variable) only then i can give it to tsort_each_child to iterate over.., hurcan