Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Iwould like to sort it by the value. I have tried the following but it doesnt sort by numerical order?10|name 8|name 12|name
%name; { while (<>) { ($number, $filename) = split (/\|/, $_); print "$number\n"; $name{$number}=$filename; } } foreach $number (sort (keys(%name))) { print "\t$number\t\t$name{$number}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sorting a hash by key
by ikegami (Patriarch) on Aug 04, 2005 at 15:16 UTC | |
|
Re: sorting a hash by key
by rinceWind (Monsignor) on Aug 04, 2005 at 15:19 UTC | |
by Anonymous Monk on Aug 04, 2005 at 15:21 UTC | |
|
Re: sorting a hash by key
by davido (Cardinal) on Aug 04, 2005 at 15:22 UTC | |
|
Re: sorting a hash by key
by Taulmarill (Deacon) on Aug 04, 2005 at 15:25 UTC | |
by Anonymous Monk on Aug 04, 2005 at 15:26 UTC | |
|
Re: sorting a hash by key
by davidrw (Prior) on Aug 04, 2005 at 16:18 UTC |