in reply to sort by field

Howdy!

Yep.

The sort function can take a subroutine that does the comparison. In this case, a Schwartzian Transform can be really useful.

@names = map { $_->[0] } sort { $a->[2] cmp $b->[2] } # index 2 for last name, 1 f +or first map { [$_, split(/\|/, $_)] } @names;

This turns each element of @names into a reference to an array containing the original item plus its two components, sorts that by the appropriate element of those arrays, then extracts the original item.

yours,
Michael