Elijah has asked for the wisdom of the Perl Monks concerning the following question:
This will display:my %hash = ( 1 => [1, One], 2 => [2, Two], 3 => [3, Three], 4 => [4, Four], 5 => [5, Five], 6 => [6, Six], 12 => [12, Twelve], ); my @sort; for my $key (keys %hash) { push @sort, "$hash{$key}[0]::$hash{$key}[1]"; } for (sort @sort) { my ($int, $alpha) = split(/::/, $_); print "Integer is: $int -- Alpha is: $alpha\n"; }
Integer is: 12 -- Alpha is: Twelve Integer is: 1 -- Alpha is: One Integer is: 2 -- Alpha is: Two Integer is: 3 -- Alpha is: Three Integer is: 4 -- Alpha is: Four Integer is: 5 -- Alpha is: Five Integer is: 6 -- Alpha is: Six
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Effective sort method?
by bobf (Monsignor) on Jan 03, 2006 at 06:33 UTC | |
|
Re: Effective sort method?
by simonm (Vicar) on Jan 03, 2006 at 06:25 UTC | |
|
Re: Effective sort method?
by l.frankline (Hermit) on Jan 03, 2006 at 06:40 UTC | |
|
Re: Effective sort method?
by superfrink (Curate) on Jan 03, 2006 at 06:50 UTC | |
|
Re: Effective sort method?
by planetscape (Chancellor) on Jan 03, 2006 at 13:05 UTC | |
by superfrink (Curate) on Jan 03, 2006 at 17:30 UTC | |
|
Re: Effective sort method?
by smokemachine (Hermit) on Jan 03, 2006 at 17:48 UTC |