#!/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]; }