well.. TIMTOWTDI I would store this as a nested array in a hash:
my %CLANS; while(<FILE>){ chomp; my($clan, @scores) = split /,/; $CLANS{$clan} = \@scores; } # to sort in order @clans_in_win_order = sort { $CLANS{$b}[0] <=> $CLANS{$a}[0] ## sort by most wins first || # then $CLANS{$a}[1] <=> $CLANS{$b}[1] ## sort by least losses || # then $CLANS{$b}[2] <=> $CLANS{$a}[2] ## sort by most points for ## etc. } keys %CLANS; ## so you print in the order of @clans_in_win_order; remember hashes don't keep any specific order... only arrays do. > -----Original Message----- > From: Steveo [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 8:48 AM > To: [EMAIL PROTECTED] > Subject: sorting data (more than one scalar involved) > > > I understand how to sort $string1 and $string2 but I have something a > little more complicated (I think at least) and I've never done this > before. This is what my data looks like (flat ascii file) > > (clan, wins, losses, points for, points against) > > dod,4,3,700,400 > cs,5,2,950,250 > hl,0,7,300,1000 > > What I want to do is read this flat ascii text file into a > script and print > it out on a webpage so the clans are ranked by wins, so on a > webpage it > would look like this: > > Clan W L PF PA > > CS 5 2 950 250 > DOD 4 3 700 400 > HL 0 7 300 1000 > > I can open and close the ascii text file. Whats an approach > for going > about sorting this data? > Steveo (aka Haiku) > [EMAIL PROTECTED] > www.linuxhaiku.com > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]