in reply to Re: Re: hash creation.
in thread hash creation.
The main difference is that you get the list of IDs as 3 .. $#scores, instead of with keys(%scores) if it were a hash.#!/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]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: hash creation.
by Anonymous Monk on Jan 04, 2001 at 14:32 UTC |