use strict; my $AoA = [[1, "apple"], [4, "pear"], [2, "plum"], [3, "orange"]]; print join("|", map {$_->[1]} sort {$a->[0] <=> $b->[0]} @{$AoA});