Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: alphabetize a hash ignoring upper/lower cases

by tstock (Curate)
on May 11, 2003 at 07:48 UTC ( #257200=note: print w/ replies, xml ) Need Help??


in reply to alphabetize a hash ignoring upper/lower cases

vladb answer works fine, and I would like to add that if the code you posted is actually what you are doing instead of a simplified example, then you really don't need the keys of the hash and it can all be written as:

my @mips = sort { lc($a) cmp lc($b) } values %mips;


Comment on Re: alphabetize a hash ignoring upper/lower cases
Download Code
Re: Re: alphabetize a hash ignoring upper/lower cases
by Anonymous Monk on May 11, 2003 at 11:59 UTC
    if you have a lot of elements doing the case conversion everytime you compare two elements this will be inefficent. i'd suggest:
    my @imps = map { $_->[1] } sort { $a->[0] cmp $b->[0] } map { [ lc $_, $_ ] } values %mips;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://257200]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-09-17 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (93 votes), past polls