use strict; # before anything else use Sort::Fields; use Data::Dumper; open(INP,"data.txt") || die "where's the file eh?"; my @data=; chomp (@data); # remove new line characters print "before sorting...\n"; print Dumper @data; #sort the data on the 2nd and the 4th field #this is numeric sort, as indicated by the "n" my @sorted = fieldsort '\t', [ '2n', '4n' ], @data; print "after sorting...\n"; print Dumper @sorted;