http://qs321.pair.com?node_id=11101379


in reply to Sort alphabetically from file

Using Hash of Arrays, is simple enough.
use strict; use warnings; my %hash; while (<DATA> =~ /(\d)\s+(\d)\s+(\d)\s+(\w+)/){ push @{$hash{$4}}, $1, $2, $3; } print "@{$hash{$_}}[0..2] $_\n" for sort keys %hash; __DATA__ 1 2 3 delta 1 2 3 apricot 1 2 3 charlie 1 2 3 bravo 1 2 3 echo 1 2 3 fox
EDIT: changed up code slightly