Try Sort::Topological.
In reply to Re: Sorting by dependencies by moritz in thread Sorting by dependencies by Anonymous Monk