http://www.perlmonks.org?node_id=1031001


in reply to Sorting by dependencies

Try Sort::Topological.

Replies are listed 'Best First'.
Re^2: Sorting by dependencies
by tobyink (Canon) on Apr 27, 2013 at 19:12 UTC

    Personally I'd go with Graph over Sort::Topological...

    use v5.12; use Graph; my @jobs = "A" .. "J"; my @rules = ( [qw/ A C /], # A before C [qw/ D B /], # D before B [qw/ J F /], # J before F [qw/ E J /], # E before J [qw/ I B /], # I before B ); my $g = "Graph"->new; $g->add_vertex($_) for @jobs; $g->add_edge(@$_) for @rules; say for $g->topological_sort;
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name