in reply to How to sort a multidimensional array

Ok. First, what you show looks like text data to perl, so I'll put it in DATA and read it like it's from a file.

#!/usr/bin/perl my @multi_array; push @multi_array, [split] for <DATA>;
I'm taking advantage of split's default arguments (split ' ', $_, where quoted space magically splits on and trims any amount of whitespace) and for's automatic loop variable, $_. The square brackets around split give me a reference to a copy of the array it produces.

If you're feeling adventurous, you can replace that chunk with

#!/usr/bin/perl # my @multi_array = map {[split]} <DATA>;
uncommented.

Vocation looks like it's at index 2, so we'll sort on that. Perl sort uses $a and $b as temporary storage for the two elements being compared.

my @by_vocation = sort {$a->[2] cmp $b->[2]} @multi_array; for (@by_vocation) { print "@{$_}\n"; } __DATA__ Jeff Goldblum Actor Mary Heartman Priest John Ericsson Mathmetician Tony Cisneros Chef
The trick is that multi-dimensional arrays in perl are just ordinary arrays, with array references as elements. Hence the arrow notation. You can work that idea as deep as you need to for many dimensions.

After Compline,
Zaxo