in reply to Sorting, given only comparisions

This is mostly a topological sort. If you substitute a7 for a8 it is entirely a topological sort. The question becomes whether cycles exist to refute the ordering.

System tsort will handle this. So will the Graph module. Wolf Book pp304-307 does, too.

After Compline,
Zaxo