The error message is right. Instead of this, which makes a string:
push(@$outputRef, "$symbol,$side,$account,$shares");
you need this, which makes an arrayref:
push(@$outputRef, [ $symbol,$side,$account,$shares ]);
or to make everything more readable further down:
push(@$outputRef, { symbol => $symbol, side => $side, account => $account, shares => $shares, });
But if that's the code you can't change, you'll have to split the strings first:
my @sorted = sort{ $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] || $a->[2] cmp $b->[2] } map { [split(',', $_)] } @$outputref;
update: removed mistaken notion of using a simple string sort.
In reply to Re: Sorting a referrenced array and need to sort by specific fields.
by thpfft
in thread Sorting a referrenced array and need to sort by specific fields.
by brentheigold
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |