Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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)


In reply to Re: results from pairs combination by suaveant
in thread results from pairs combination by lipong

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found