#!/usr/bin/perl while (<>) { @tmp = split(/,/); push @failures, [ @tmp ]; } @sorted = sort { $a->[6] cmp $b->[6] } @failures; for $array_ref ( @sorted ) { print "@$array_ref \n" ;