my @entries; ... # Loop over your files and extract data push @files, { 'array_position' => $array_position, 'run' => $run, 'copy' => $copy, 'district' => $district, 'total' => $total }; ... my @sorted_files = sort { $a->{'run'} <=> $b->{'run'} || # use '<=>' for numbers $a->{'copy'} <=> $b->{'copy'} || $a->{'district'} <=> $b->{'district'} || $a->{'total'} <=> $b->{'total'} } @files;