#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @filter; <>; # read one line from the file/stdin while (<>) { # read other lines chomp; # remove "\n" from the end of the line push @filter,[(split /\t/,$_)]; # create an array of the line by splitting it by , make a reference of it and push the reference to the @filter array } @filter = sort { $a->[4] <=> $b->[4] } @filter; # sort the array by 5th element of embedded arrays print Dumper \@filter;