Ranking Items... Help!

They have: 117 posts

Joined: Mar 2000

Okay, so I have this file and each lines contains variables separated by | :

open(DATA, "$data_path\\$FORM{'id'}\\affiliates.txt");
if ($flock eq "y") {
flock DATA, 2;
}
@data = <DATA>;
chomp @data;
close(DATA);

foreach $line (@data) {
  ($name, $variable1, $variable2, $date) = split(/\|/, $line);
'

$variable1 is a number. My question is how do I sort the items from greatest to least based on $variable1?? Thanks in advance!

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

I'm not a Perl expert but maybe this link can give you some ideas: http://www.perl.com/pub/a/2000/12/begperl4.html#sorting

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.