Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: reordering segments to form a polygon

by Jaap (Curate)
on Aug 13, 2004 at 10:37 UTC ( [id://382601]=note: print w/replies, xml ) Need Help??


in reply to Re: reordering segments to form a polygon
in thread reordering segments to form a polygon

Although VERY beautiful, it is incorrect:
#!/cadappl/bin/perl -w -Ilib use strict; my @r = ( [ 5, 3, 5, 5 ], [ 1, 1, 2, 1 ], [ 2, 3, 5, 3 ], [ 5, 5, 1, 5 ], [ 2, 1, 2, 3 ], [ 1, 5, 1, 1 ], ); my @x = sort { $a->[2] <=> $b->[0] || $a->[3] <=> $b->[1] || -1 } @r; foreach (@x) { print "$_->[0],$_->[1],$_->[2],$_->[3]\n"; }
Output:
1,5,1,1 1,1,2,1 2,1,2,3 5,5,1,5 2,3,5,3 5,3,5,5
I changed the order of @r to show the error.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://382601]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found