print a hash ordered by value

Y

Yiping Zhan

What is a good way of getting a printed output like:

d 7
b 6
a 3
c 1

if I have a hash like:

%h = qw(a 3 b 6 c 1 d 7);

Thank you!

-- Newbie
 
A

Anno Siegel

Yiping Zhan said:
What is a good way of getting a printed output like:

d 7
b 6
a 3
c 1

if I have a hash like:

%h = qw(a 3 b 6 c 1 d 7);

That's a frequently asked question. You can look up the answer through
perldoc -q 'sort a hash'.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top