List and order

Nic nospam at nospam.nospam
Tue May 16 08:58:35 CEST 2006


Perfect. Thanks.
Nic

"Peter Otten" <__peter__ at web.de> ha scritto nel messaggio 
news:e4aahn$l16$01$1 at news.t-online.com...
> Nic wrote:
>
>> The only problem is that from:
>> 12
>> 22
>> 21
>> In spite of writing
>> 12 12 22
>> it writes
>> 12 21 22
>> Do you know how is it possible to delete also this last trouble?
>
> I thought that the two 12 were a typo, but it seems you want to reorder 
> the
> nodes inside an edge, too. Here's a fix that normalizes the edge before
> sorting the list of edges:
>
> edges = [sorted((ddeg[u], ddeg[v])) for u, v in G.edges()]
> edges.sort()
> for a, b in edges:
> print a, b,
> print
>
> Peter
>
> 





More information about the Python-list mailing list