@sortedCollectionData = sort { $collectionData[ $b ]{CollectionId} <=> $collectionData[ $a ]{Coll +ectionId} || $collectionData[ $b ]{Modified} cmp $collectionData[ $a ]{Modified +} } 0 .. $#collectionData;
What you are storing here are numbers (specifically from 0 to $#collectionData), so @sortedCollectionData now contains these numbers in some order or another. And then you write $sortedCollectionData[$i]{'Status'}, and try to access one of these numbers as if it was a hash reference.
You might want to sort your hash refs directly instead:
@sortedCollectionData = sort { $b->{CollectionId} <=> $a->{CollectionId} || $b->{Modified} cmp $a->{Modified} } @collectionData;
In reply to Re: Sorting an array or hashes
by moritz
in thread Sorting an array or hashes
by hok_si_la
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |