List and order

Miki miki.tebeka at gmail.com
Mon May 15 07:19:28 EDT 2006


Hello Nic,

Python lists has a very powerfull buid-in "sort".

edges = list(G.edges())
edges.sort(key = lambda u, v: (ddeg(u), ddeg(v)))
for u, v in edges:
    print u,v,  # Note the training comma to avoid newline
print

HTH,
Miki
http://pythonwise.blogspot.com




More information about the Python-list mailing list