Are the region numbers sequential, or discontiguous?
If sequential:
my @StatsArray; push @{$StatsArray[$RegionNum]}, { AR => $AR[$RegionNum], BCR => $BCR[$RegionNum], };
If sparse, this:
my %Stats; push @{$Stats{$RegionNum}}, { ... };
Then you could do this:
my @sorted = sort { $a->{AR} <=> $b->{AR} } @{ $StatsArray[$RegionNum] + };
...for example.
It might be that you're getting to the point where a database would scale better though. Another approach might be to just build a binary tree, maintaining nodes in sorted order. This allows for relatively inexpensive inserts and searches. But it does sound like you might need the scalability of a DB approach.
Dave
In reply to Re: How to improve this data structure?
by davido
in thread How to improve this data structure?
by fiddler42
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |