in reply to Re: Sort mechanics problems ...
in thread Sort mechanics problems with objects and potentially contradicting comparisons (would cause infinite loop)

You are indeed correct that the classic solution to the problem is a graph and the type of sort is topological. However, the perl code is not compelled to support every step of the theory. It turns out to be much simpler in practice with perl sort:
if $a is dependent on $b, return -1 if the reverse, return 1 otherwise return 0
this lets $a and $b remain unsorted relative to each other where there is no dependency.

One world, one people

Replies are listed 'Best First'.
Re^3: Sort mechanics problems ...
by Anonymous Monk on Jun 02, 2016 at 17:12 UTC
    ...But, as you've discovered, it's not actually that simple. Another issue is that you'll need a stable sort algorithm for this to work (see the sort pragma). We're trying to tell you that sort is really not the right tool for this job.