in reply to How do you specify which fields to sort by when sorting an array.
I took the liberty of fixing the name of @outputRef (which is not a reference) and pushing each row as an anonymous array. I also use numeric comparisons on the phone numbers.my @output; while (<INPUT_FILE>) { push @output, [ split(',', $_, 4) ]; } my @sorted = sort { $a->[0] cmp $b->[0] || $a->[3] <=> $b->[3] } @output;
|
---|