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

Re^2: beginner - ordering tuples

by Anonymous Monk
on Nov 13, 2010 at 01:09 UTC ( [id://871181]=note: print w/replies, xml ) Need Help??


in reply to Re: beginner - ordering tuples
in thread beginner - ordering tuples

I'm so much of a beginner I can't follow that. I will try and work it out but any help is appreciated.

Replies are listed 'Best First'.
Re^3: beginner - ordering tuples
by Anonymous Monk on Nov 13, 2010 at 01:13 UTC
    the input file isn't in that format. i will have the values in 2 variables called $a and $b after i have parsed the line and i know $b will be higher than a for every row.
      You might not want to use $a and $b, because those are built-in globals used by certain functions (eg sort).

      Assuming you're looping over each line:

      my @pairs; while (<$filehandle>) { # or whatever loop construct # parse line and set $foo and $bar here # for example: chomp; my ($foo, $bar) = /(\d+)/g; # add to array push @pairs, [ $foo, $bar ]; } # sort array # NB: these are the special $a and $b, not yours @pairs = sort { $$a[0] <=> $$b[0] } @pairs;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2024-04-18 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found