in reply to sorting first column

Something like this:
use warnings; use strict; chomp(my @data_array=<DATA>); print join $/ => map{$_->[0]} sort{$a->[1] <=> $b->[1]} map{[$_,(split/\s+/,$_,2)[1]]} @data_array; __DATA__ AA 34 AB 22 AC 12
..produces..
AC 12 AB 22 AA 34
Update: And if the above is using too much power :), you can simply use a hash like so:
my %hash; while(<DATA>){ next if /^\s*$/; my @data = split; $hash{$data[1]} = $data[0] } print $hash{$_},' ',$_,$/ for sort{$a<=>$b} keys %hash; __DATA__ AA 34 AB 22 AC 12
Update 2: On the Hash method:
Please note that the keys used in the hash must be UNIQUE for the hash method to work properly as intended.
ww thanks for catching that.
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me