Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: sorting an associated array

by sundialsvc4 (Abbot)
on Apr 23, 2014 at 20:31 UTC ( #1083448=note: print w/replies, xml ) Need Help??

in reply to sorting an associated array

As an aside, I once worked with a group that liked to tie() hashes to Berkely-DB files with millions of records in each.   (Dunno, I guess they mistrusted SQL?)   Anyway, they would do things like that, and the fairly-limited systems would choke because all of those keys had to be pulled out into memory in order to be sorted.   I observed that the each() function when applied to such files would automagically walk the index-tree and thus produce the keys in ascending order, eliminating what was a very costly process.

If you must produce keys in sorted order, this process will work as described.   However, if the hashes in question are large, and particularly if they are ties, be very aware of what you are actually asking the computer to do.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1083448]
[Eily]: it stays unapproved after I try to moderate it I mean
[chacham]: I'm sure this is old, but i just came across it: If you put a million monkeys at a million keyboards, one of them will eventually write a Java program. The rest of them will write Perl programs.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2018-04-23 16:00 GMT
Find Nodes?
    Voting Booth?