in reply to how do i sort hash by key numerically

for $key ( sort {$a<=>$b} keys %hash) { print "($key)->($hash{$key})\n"; }

Replies are listed 'Best First'.
Re: Answer: how do i sort hash by key numerically
by arhuman (Vicar) on Mar 07, 2001 at 14:01 UTC
    I've set {$a<=>$b} to show you how to change the way the list should be sorted...
    You could sort on :
    key decreasing order : {$b<=>$a}
    values-> {$hash{$a}<=>$hash{$b}}
    key length -> {length{$a}<=>length{$b}}
    or whatever...