Tom Jones wrote: > Hi, > > Consider tuples of the above numbers in the form: > (a,b) > > Suppose this relation means: > a depends on b > > Given a list of tuples, I would like an algorithm to return the proper > ordering of the elements...and if the ordering has a loop (which in this > case, prevents a proper ordering), then it should return None.
Google for "topological sort python". There are several implementations out there. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list