@sorted_array = map {$_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, (split/,/)[2] ] } # retrieve the third key @original_array;