Re: Sorted Hash
- From: bugbear <bugbear@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Nov 2007 12:36:22 +0000
xhoster@xxxxxxxxx wrote:
"palexvs@xxxxxxxxx" <palexvs@xxxxxxxxx> wrote:I filled hash and then printed it (sorted by key):
my %hs = (
key10 => 5,
key5 => b,
aey9 => 7,
)
foreach my $k (sort keys %hs) { print "$k $hs{$k}\n"; }
key - string ([0-9A-F]{72}), 50K records.
How do it more effective?
What is ineffective about the current way?
You could keep the structure sorted throughout its lifetime by using
a tied hash or a non-hash structure, but the overhead of doing so
is almost certainly going to be greater than a one-time sort.
Yes; maintaining a sorted sequence is "like" insertion sort.
BugBear
.
- References:
- Sorted Hash
- From: palexvs@xxxxxxxxx
- Re: Sorted Hash
- From: xhoster
- Sorted Hash
- Prev by Date: Re: Sorted Hash
- Next by Date: Re: Sorted Hash
- Previous by thread: Re: Sorted Hash
- Next by thread: Re: Sorted Hash
- Index(es):