in reply to Problem with sorting numbers.

cmp compares strings. You should use <=> instead.

Your code will only print one record if two have the same number, because the hash key $sorted[0] is not unique. The second (and third, etc) time you set a given hash element, the previously set value is lost. What follows is the same program, but it uses an array to avoid erasing records with the same number.

use strict; use warnings; print "Content-type: text/html\n\n"; my @records; while (<DATA>) { chomp; push(@records, [ split(/\|/) ]); } print "$_->[0]|$_->[1]|$_->[2]<BR>\n" foreach sort { $b->[0] <=> $a->[0] } @records;