Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Why not use a hash?

by tedv (Pilgrim)
on Dec 12, 2000 at 21:56 UTC ( #46283=note: print w/replies, xml ) Need Help??

in reply to sort my arrayref

From the example data, you might be better off with a hash. It's much, much easier to manipulate (oops => 0, happy => 2, word => 4) than crazy array accessing. On top of that, it's clear you don't care about the original order of the array because you're sorting it. The only reason you might not be able to use an array is if you want to have duplicate entries (like [happy, 2], [happy, 2], or [oops, 0], [happy, 0], [happy, 2]. The second one doesn't have any true duplicates, but it's constructed in a way that you can't use either the left or the right element for the hash keys. But I doubt this is the case. Determine which value you will more commonly use for access (probably the number) and use it for hash keys.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://46283]
[Corion]: Meh. My bank removed (part of) their CSV download facilities. Now I will either have to implement a full scraper or automate the download using the HBCI interface instead (or just get a new account elsewhere...)
[Corion]: On the upside, I spend a lot of time thinking this weekend about how to actually implement rate limiting for futures, and if things work out, maybe even loading a configuration from an external file makes sense

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-10-23 08:19 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (277 votes). Check out past polls.