foreach my $sort (@sorted){ print "

$sort->[2]

"; } # sort the array of arrays by price @sorted = sort {$main::a->[2] <=> $main::b->[2]} @sorted; foreach my $sort (@sorted){ print "

$sort->[2]

"; }