Re: Sorted Hash



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
.