Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sorting - lower to upper

by mifflin (Curate)
on Jul 15, 2004 at 15:58 UTC ( [id://374701]=note: print w/replies, xml ) Need Help??


in reply to Sorting - lower to upper

How about this...
erickn@isfe:/home/erickn> cat t use warnings; $hash{John} = ''; $hash{Bob} = ''; $hash{xavier} = ''; $hash{alice} = ''; for my $key (sort {ucfirst($b) cmp lcfirst($a)} keys %hash) { print "$key\n"; } erickn@isfe:/home/erickn> perl t alice xavier Bob John

Replies are listed 'Best First'.
Re^2: Sorting - lower to upper
by shemp (Deacon) on Jul 15, 2004 at 16:30 UTC
    Nope, wont work. Just consider $a = 'amy', $b = 'Ask'. after the case conversion, its comparing then as they were originally, and the capital comes before the lower case.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-19 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found