my @unsorted = ; my @sorted = sort byPhone @unsorted; #### sub byPhone { return (split(/\|/, $a))[1] cmp (split(/\|/, $b))[1]; }