Started work on issue #10.

If a circular dependency is detected, sorting should not take place,
since it would get stuck in an infinite loop. Consistency checks are
unoptimised.