On Mon, Feb 25, 2008 at 4:32 AM, Anirban Adhikary
<[EMAIL PROTECTED]> wrote:
> Dear List
>
> I need to delete each element after every execution of the foreach loop and
> I need to update & sorted the @arr1 after every execution of the foreach
> loop. I have tried a lot but not able to do this
On 02/25/2008 04:32:42 AM, Anirban Adhikary wrote:
-> Dear List
->
-> I need to delete each element after every execution of the foreach
-> loop and
-> I need to update & sorted the @arr1 after every execution of the
-> foreach
-> loop. I have tried a lot but not able to do this Pls
-
Dear List
I need to delete each element after every execution of the foreach loop and
I need to update & sorted the @arr1 after every execution of the foreach
loop. I have tried a lot but not able to do this Pls
help...
Thanks & Regards
Anirban Adhikary
On Mon, Feb 25, 2008
Anirban Adhikary wrote:
Dear List
Hello,
I have written the following code .
use Data::Dumper;
%file = (14 => "GGG",
11 => "AAA",
101 => "EEE",
1 => "TTT");
print Dumper \%file;
@arr1 = sort { $file{$b} cmp $file{$a} } keys %file; #the oldest ent
On Mon, 15 Dec 2003 00:17:17 -0800
"B. Rothstein" <[EMAIL PROTECTED]> wrote:
> I have a hash where each key is a first name linked to a last name, any
> suggestions on how to loop through the hash to sort the list by the last
> names?
Something like this perhaps?
#!/usr/bin/perl -w
use strict
On 12/15/2003 3:17 AM, B. Rothstein wrote:
I have a hash where each key is a first name linked to a last name, any
suggestions on how to loop through the hash to sort the list by the last
names?
Check the Perl FAQ.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [
cketta, Ronald'
Cc: [EMAIL PROTECTED]
Subject: Re: hash sorting
Timothy Johnson wrote:
> Try using 'cmp' instead of '<=>' in your sort. Then it will sort
> alphanumerically.
>
This does not appear to help, perldoc perlop says:
"Binary "cmp&qu
Ronald Yacketta wrote:
> Can some please help here :)
>
> I have the following
>
>
> sub dbMonthlySelect() {
> my $query;
> my $result;
>
> $query = "select * from mbstats_se where
> STATDATE=TO_DATE('12/30/02','MM/DD/YY')"; $result =
> &doQuery($query,'
Timothy Johnson wrote:
Try using 'cmp' instead of '<=>' in your sort. Then it will sort
alphanumerically.
This does not appear to help, perldoc perlop says:
"Binary "cmp" returns -1, 0, or 1 depending on whether the left argument
is stringwise less than, equal to, or greater than the right a
Try using 'cmp' instead of '<=>' in your sort. Then it will sort
alphanumerically.
-Original Message-
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 10, 2003 4:43 PM
To: [EMAIL PROTECTED]
Subject: hash sorting
Can some please help here :)
I have the following
I think you're missing the intent of the original post. The poster wanted
to know how to sort on the value. Otherwise you're correct.
-Original Message-
From: LRMK
To: Kurtis
Cc: [EMAIL PROTECTED]
Sent: 11/9/02 9:55 AM
Subject: Re: Hash Sorting?
hashes are do not need to
hashes are do not need to be sorted becouse they are key/value paires
if u need to get the values of the ascending order of keys
first load the keys to a array using following
@keylist = keys %hash;
#then sort the key list
@keylist = sort @keylist;
#now you have keys in ascending order so u ca
2 5:10 PM
To: [EMAIL PROTECTED]
Subject: RE: Hash Sorting?
Timothy Johnson wrote:
>
> I guess it depends on whether you want the list of keys sorted by which
> has
> the highest value or the values themselves. The most common use of this
> for me is when I want to sort the ke
Timothy Johnson wrote:
>
> I guess it depends on whether you want the list of keys sorted by which
> has
> the highest value or the values themselves. The most common use of this
> for me is when I want to sort the keys or values of a hash using a hash
> reference, for example if I'm calculating
ot;$_ => $ref->{$_}\n";
}
}
-Original Message-
From: david [mailto:dzhuo@;looksmart.net]
Sent: Thursday, November 07, 2002 4:25 PM
To: [EMAIL PROTECTED]
Subject: Re: Hash Sorting?
Kurtis wrote:
> Hey Timothy,
>
> I couldn't get it to work...I know you can s
Kurtis wrote:
> Hey Timothy,
>
> I couldn't get it to work...I know you can sort on keys, so I went
> out
> the cheap wayI switched the values with my keys...it's no problem
> because my values are unique also
>
why not just sort on the values?
foreach my $value (sort {$a <=> $
7;.
-Original Message-
From: Kurtis [mailto:kurtis@;asdal.net]
Sent: Wednesday, November 06, 2002 4:10 PM
To: Timothy Johnson
Cc: [EMAIL PROTECTED]
Subject: Re: Hash Sorting?
Hey Timothy,
I couldn't get it to work...I know you can sort on keys, so I went out
the cheap way.
keys %hash)
{
$value=$hash($key);
#do something..
}
- Original Message -
From: "Timothy Johnson" <[EMAIL PROTECTED]>
To: "'Perry, Alan'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, November 06, 2002 6:17 PM
Subject: RE: Ha
Right you are. sorry.
-Original Message-
From: Perry, Alan [mailto:aperry@;loislaw.com]
Sent: Wednesday, November 06, 2002 3:17 PM
To: [EMAIL PROTECTED]
Subject: RE: Hash Sorting?
I think the second example should be:
foreach(sort {$hash{$a} cmp $hash{$b}} keys %hash){
do
urtis'; [EMAIL PROTECTED]
Subject: RE: Hash Sorting?
You can use the longer form of sort for this. You may have seen this
before:
my @array = sort {$a cmp $b} @unsorted;
#$a and $b are default variables for the sort command.
#to reverse sort, you can reverse $a and $b.
You can also do this:
fo
You can use the longer form of sort for this. You may have seen this
before:
my @array = sort {$a cmp $b} @unsorted;
#$a and $b are default variables for the sort command.
#to reverse sort, you can reverse $a and $b.
You can also do this:
foreach(sort {$hash{$a} cmp $hash{$b}} keys $hash){
21 matches
Mail list logo