If I've got a grasp on your problem, what you want to do is sort a list of IDs by their associated point values. You certainly could do that with a hash, where the IDs are keys and the points are values, but given your set of IDs you don't need to; an array would work well for the whole process.
#!/usr/local/bin/perl -w
use strict;
my @scores = (
undef, undef, undef, # skip IDs 0, 1, and 2
7, 28, 19, 3, 36,
);
my @ids_by_score =
sort { $scores[$b] <=> $scores[$a] } # higher scores first
3 .. $#scores; # IDs 3 to max ID
print "ID: Score\n";
for my $id (@ids_by_score) {
printf "%2d: %5d\n", $id, $scores[$id];
}
The main difference is that you get the list of IDs as 3 .. $#scores, instead of with keys(%scores) if it were a hash. | [reply] [d/l] |
Hey! It worked!
Thanks a million to *everyone* who helped with this.
And, btw, you're correct -- office gambling sure is getting
high-tech.
| [reply] |