List and order

Miki miki.tebeka at gmail.com
Mon May 15 13:19:28 CEST 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