On Sat, Jun 02, 2001 at 06:13:04PM +1000, iain truskett wrote:
> Rob talked about
>
> foreach $value(sort {$a <=> $b} (values(%hash)) {
> print $value;
> }
>
> vs.
>
> foreach $value(sort byNum (values(%hash)) {
> print $value;
> }
>
> sub byNum {
> $a <=> $b;
> }
>
>
> Am I corr
Rob talked about
foreach $value(sort {$a <=> $b} (values(%hash)) {
print $value;
}
vs.
foreach $value(sort byNum (values(%hash)) {
print $value;
}
sub byNum {
$a <=> $b;
}
Am I correct in thinking that the anonymous subroutine is vaguely more
efficient?
--
iain.
Paul Hodges wrote:
: Try flipping the hash.
:
: my %flipped;
: @flipped{values %HASH} = keys %HASH;
:
: That makes the keys of %HASH the values of %flipped, with the matching
: values of %HASH being the keys to which they are assigned.
: Now just do it the easy way.
:
: for my $key (sort ke
--- "Maynard, Garth" <[EMAIL PROTECTED]> wrote:
> Caution: if you have any data that is repetitive, you will lose
> information during the flipping process.
An excellent point.
Shouldn't be the case here, since the values were the order of entry,
but it needed pointing out.
Caution: if you have any data that is repetitive, you will lose information
during the flipping process.
Subject: Re: Sorting a hash by value, and displaying the key
--- David Michael <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a hash that needs to be displayed in a cert
--- Paul <[EMAIL PROTECTED]> wrote:
>
> --- David Michael <[EMAIL PROTECTED]> wrote:
> > Hello,
> > I have a hash that needs to be displayed in a certain order. I
> > tried
> >
> > foreach $key (sort (keys %HASH)) {
> > print $key;
> > }
> >
> > that sorts alphabeti
--- David Michael <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a hash that needs to be displayed in a certain order. I
> tried
>
> foreach $key (sort (keys %HASH)) {
> print $key;
> }
>
> that sorts alphabetically. I need it in the order it was
> inserted, so I made
On Thu, May 31, 2001 at 02:41:32PM -0500, David Michael wrote:
> Hello,
> I have a hash that needs to be displayed in a certain order. I tried
>
> foreach $key (sort (keys %HASH)) {
> print $key;
> }
>
> that sorts alphabetically. I need it in the order it was inserte
David Michael wrote:
: I have a hash that needs to be displayed in a certain order. I tried
:
: foreach $key (sort (keys %HASH)) {
: print $key;
: }
:
: that sorts alphabetically. I need it in the order it was inserted, so I made the
:value a number that increased f
On Thu, 31 May 2001, David Michael wrote:
> Hello,
> I have a hash that needs to be displayed in a certain order. I tried
>
> foreach $key (sort (keys %HASH)) {
> print $key;
> }
>
> that sorts alphabetically. I need it in the order it was inserted,
> so I made the value a
Hello,
I have a hash that needs to be displayed in a certain order. I tried
foreach $key (sort (keys %HASH)) {
print $key;
}
that sorts alphabetically. I need it in the order it was inserted, so I made the
value a number that increased for each key. I need to sort by
11 matches
Mail list logo