in reply to Re^2: A more efficient sort or heap algorithm...
in thread A more efficient sort or heap algorithm...

I wasn't sure how to implement that using the built in sort function. It allows me to keep track of and print out the information for both regions.

Just try to sort the indices and then map both arrays by them:

my @ind_srtd = sort { $array->[$a] cmp $array->[$b] } (0..$#$array); my @array_srtd = map { $array->[$_] } @ind_srtd; my @array_which_srtd = map { $array_which->[$_] } @ind_srtd;

I didn't tested it thoroughly, but should look something like this.