Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: results from pairs combination

by suaveant (Parson)
on Oct 01, 2008 at 17:33 UTC ( [id://714848]=note: print w/replies, xml ) Need Help??


in reply to results from pairs combination

Update Never mind, all wrong. Did the original post get updated?

So you want a sort? Ok.

@sorted_pairs = sort { my@a1 = split',',$a; my@b1 = split',',$b; $a1[0 +] <=> $b1[0] || $a1[1] <=> $b1[1] } @pairs;
The first match returns 0 for a match, so it falls through to the second comparison for things like 2,6 2,7

You need to split the values, otherwise 10,1 would sort before a pair like 2,6, and just using numeric sorting breaks at the comma. It would be even better to split the values ahead of time, but probably not necessary. (You could always use a Schwarzian Transform).

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re^2: results from pairs combination
by moritz (Cardinal) on Oct 01, 2008 at 17:40 UTC
    Did the original post get updated?
    Yes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-05-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found