in reply to Sort mechanics problems with objects and potentially contradicting comparisons (would cause infinite loop)
One of the table declarations I configure takes the form: "FK", local column, foreign table name, foreign PK. So I have to sort the CSVs so that wherever such a declaration exists, the foreign table is created before the table in which the FK declaration is made.
Why not use a Dependency graph?
use Graph; my $g = Graph->new(directed => 1); $g->add_edge(split /:/) for qw/ a:d a:b c:b d:c /; my @order = $g->topological_sort; print join(", ", @order), "\n"; __END__ a, d, c, b
Hope this helps,
-- Hauke D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort mechanics problems ...
by anonymized user 468275 (Curate) on Jun 02, 2016 at 11:18 UTC | |
by Anonymous Monk on Jun 02, 2016 at 17:12 UTC | |
|
Re^2: Sort mechanics problems ...
by anonymized user 468275 (Curate) on Jun 15, 2016 at 13:17 UTC |