sort {
$a->[0] cmp $b->[0]
or $a->[1] cmp $b->[1] # *
or $a->[2] cmp $b->[2] # *
or ... # *
} @AoA
# *) only check if former was equal == 0 == false
if you don't know the number of fields, recursive comparisons come in handy.
I'm bu-la-zy, so constructing the recursion is left as exercise. ;-)
HTH!
update
In hindsight ... this particular case could also be solved in a loop.
So think about a more complicated data structures like trees to be sorted.
In the end it's about convenience ... every loop can be expressed as recursion and vice versa.
°) see examples in code from line 39 onwards |