in reply to sorting first column
..produces..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
Update: And if the above is using too much power :), you can simply use a hash like so:AC 12 AB 22 AA 34
Update 2: On the Hash method: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
|
|---|