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

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;