in reply to how do i sort hash by key numerically
Jouke Visser, Perl 'Adept'#!/usr/bin/perl -w %hash=( 89=>3, 45=>2, 1 =>5, 40=>3); foreach (sort { $a <=> $b } keys(%hash) ) { print "key: $_ value: $hash{$_}\n" }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Answer: how do i sort hash by key numerically
by Tyke (Pilgrim) on Mar 07, 2001 at 16:35 UTC |