# File lib/ancestry/class_methods.rb, line 62 def sort_by_ancestry(nodes) arranged = nodes.is_a?(Hash) ? nodes : arrange_nodes(nodes.sort_by{|n| n.ancestry || '0'}) arranged.inject([]) do |sorted_nodes, pair| node, children = pair sorted_nodes << node sorted_nodes += sort_by_ancestry(children) unless children.blank? sorted_nodes end end