Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to sort a perl array in descending and printing out the top 5?

Posted on 2006-10-23
3
Medium Priority
?
456 Views
Last Modified: 2008-02-07
Hi. I need to sort a perl array in descending then printing out the top 5? help would be greatly apreciated.
0
Comment
Question by:micromarch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Accepted Solution

by:
NorCal2612 earned 1000 total points
ID: 17793097
@array = sort { $b <=> $a } @array;

for ($i = 0; $i < 5; $i++) { print $array[$i] . "\n"; }
0
 
LVL 84

Expert Comment

by:ozo
ID: 17793683
@array = reverse sort @array;
print "@array[0..4]\n";
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question