$song{$chart_position}{TITLE} = 'Insomnia'; $song{$chart_position}{VISITOR_POS} = 10; #### for $pos ( sort { $a <=> $b } keys %song ) { print "$pos $song{$pos}{VISITOR_POS} $song{$pos}{TITLE}\n"; } #### for $pos ( sort { $song{$a}{VISITOR_POS} <=> $song{$b}{VISISTOR_POS} } keys %song ) { print "$pos $song{$pos}{VISITOR_POS} $song{$pos}{TITLE}\n"; }