CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Sorting 2 Hashes

 



andy7t
User

Sep 28, 2003, 3:44 AM

Post #1 of 3 (510 views)
Sorting 2 Hashes Can't Post

Hi,

Another football question i'm afraid.

Daveorg told me to sort hashes like this:


foreach (sort { $points{$b} <=> $points{$a} } keys %points) { }

This works fine- but my next problem is how do i do two sorts?

I need to sort not only by points, but also by goaldifference
($goaldifference)

So, i need it to first sort it into Points, and if there is more than one team with the same amount of points, then sort by goaldifference.

Thanks

Andrew


KevinR
Veteran


Sep 28, 2003, 11:08 AM

Post #2 of 3 (507 views)
Re: [andy7t] Sorting 2 Hashes [In reply to] Can't Post

see if any of this will help you:

http://www.perldoc.com/perl5.8.0/pod/perlfaq4.html#How-do-I-sort-an-array-by-(anything)-
-------------------------------------------------


davorg
Thaumaturge / Moderator

Sep 28, 2003, 3:09 PM

Post #3 of 3 (504 views)
Re: [andy7t] Sorting 2 Hashes [In reply to] Can't Post

Some of the code in this article might be useful to you.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives