use strict; use warnings; my @records; my @list; my @sorted_recs; while () { chomp; my @tokens = split; my @record = @tokens[3, 4, 5, 6, 10, 11]; push @records, \@record; } print join (', ', @$_), "\n" for sort {$a->[3] <=> $b->[3]} @records; __DATA__ 0 1 2 3 4 5 6 7 8 9 10 11 1 1 2 2 4 5 2 7 8 9 10 11 2 1 2 1 4 5 9 7 8 9 10 11