Re: Sorted Hash



"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.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.



Relevant Pages

  • Re: What is the use of s { } { }
    ... The costs of publication of this article were defrayed in part by the ... payment of page charges. ...
    (comp.lang.perl.misc)
  • Re: How do you use IPC::Open3....
    ... The costs of publication of this article were defrayed in part by the ... payment of page charges. ...
    (comp.lang.perl.misc)
  • Re: comma puzzle
    ... Why does the first element become 1? ... The costs of publication of this article were defrayed in part by the ... payment of page charges. ...
    (comp.lang.perl.misc)