in reply to Using a sorting subroutine in a module with an array of arrays as parameters

@age = ( @f1 = (amy,35), @f2=(bill,55), @f3=(george,28), @f4=(jason,71 +)); @age = sort personal::sortAge(\@age);

this is not what you want¹ ... anonymous arrays are written in brackets.

you rather meant:

DB<150> @age => (["amy", 35], ["bill", 55], ["george", 28], ["jason", 71]) DB<151> sort personel::sortAge @age => (["jason", 71], ["bill", 55], ["amy", 35], ["george", 28])

your syntax produced a flat list, not a nested AoA.

DB<153> @age = ( @f1 = (amy,35), @f2=(bill,55), @f3=(george,28), @f4 +=(jason,71)); => ("amy", 35, "bill", 55, "george", 28, "jason", 71)

see perldsc for details.

If I were you I would define sortAge() to sort itself

DB<157> @age = ( ["amy", 35], ["bill", 55], ["george", 28], ["jason" +,71]); => (["amy", 35], ["bill", 55], ["george", 28], ["jason", 71]) DB<158> sub personel::sortAge { sort { $b->[1] <=> $a->[1] } @_} DB<159> personel::sortAge @age => (["jason", 71], ["bill", 55], ["amy", 35], ["george", 28])

otherwise better rename your sortAge to cmpAge, cause your code doesn't "sort" it "compares".

Cheers Rolf

( addicted to the Perl Programming Language)

¹) and the code you posted before updating wasn't even valid perl.