Re: Hash Sorting Problem

2008-02-25 Thread Chas. Owens
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

Re: Hash Sorting Problem

2008-02-25 Thread MK
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 -

Re: Hash Sorting Problem

2008-02-25 Thread Anirban Adhikary
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

Re: Hash Sorting Problem

2008-02-25 Thread John W. Krahn
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

Hash Sorting Problem

2008-02-25 Thread Anirban Adhikary
Dear List 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 entry lies at the top position print D

Re: hash containing a hash, sorting keys help

2007-05-05 Thread Ken Foskey
On Sat, 2007-05-05 at 07:19 -0700, Tom Phoenix wrote: > On 5/5/07, Ken Foskey <[EMAIL PROTECTED]> wrote: > > > foreach my $child (sort keys( $parent{$pid} )) { > > dump_process( $child ); > > } > > > > Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi > > lin

Re: hash containing a hash, sorting keys help

2007-05-05 Thread Tom Phoenix
On 5/5/07, Ken Foskey <[EMAIL PROTECTED]> wrote: foreach my $child (sort keys( $parent{$pid} )) { dump_process( $child ); } Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi line 46, near "} )" That's saying that you're giving the keys() operator a hash

Re: hash containing a hash, sorting keys help

2007-05-05 Thread Rob Dixon
Ken Foskey wrote: I cannot get the syntax right for child lookup, Data::Dumper confirms that I have the structure as I expect (logic may be totally wrong though). I going to do a webpage pstree command. foreach my $child (sort keys( $parent{$pid} )) { dump_process( $child ); }

Re: hash containing a hash, sorting keys help

2007-05-05 Thread yaron
) Asia/Jerusalem שבת 5 מאי 2007 Subject: hash containing a hash, sorting keys help I cannot get the syntax right for child lookup, Data::Dumper confirms that I have the structure as I expect (logic may be totally wrong though). I going to do a webpage pstree command. foreach my $chil

hash containing a hash, sorting keys help

2007-05-05 Thread Ken Foskey
I cannot get the syntax right for child lookup, Data::Dumper confirms that I have the structure as I expect (logic may be totally wrong though). I going to do a webpage pstree command. foreach my $child (sort keys( $parent{$pid} )) { dump_process( $child ); } Type of arg 1 to key

Re: hash sorting

2003-12-14 Thread Owen
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

Re: hash sorting

2003-12-14 Thread Randy W. Sims
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: [

hash sorting

2003-12-14 Thread B. Rothstein
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? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: hash sorting

2003-01-10 Thread Timothy Johnson
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

Re: hash sorting

2003-01-10 Thread david
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,'

Re: hash sorting

2003-01-10 Thread Wiggins d'Anconia
could skip any non /I\d+/ keys in the hash and then print them at the bottom. There should be a way to get sort to do it correctly but this escapes me at the moment... http://danconia.org -Original Message- From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]] Sent: Friday, January 10, 20

RE: hash sorting

2003-01-10 Thread Timothy Johnson
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 her

hash sorting

2003-01-10 Thread Yacketta, Ronald
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,'dbMonthlySelect'); my $i = $result->fetchrow_h

RE: Hash Sorting?

2002-11-10 Thread Timothy Johnson
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

Re: Hash Sorting?

2002-11-09 Thread LRMK
can access values in that order eg:- #first 1 is $hash{$keylist[0]} #2 nd $hash{$keylist[1]} #n th one $hash{$keylist} - Original Message - From: "Kurtis" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 07, 2002 5:00 AM Subject: Has

RE: Hash Sorting?

2002-11-07 Thread Timothy Johnson
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

RE: Hash Sorting?

2002-11-07 Thread david
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

RE: Hash Sorting?

2002-11-07 Thread Timothy Johnson
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

Re: Hash Sorting?

2002-11-07 Thread david
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 <=> $

RE: Hash Sorting?

2002-11-06 Thread Timothy Johnson
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.

Re: Hash Sorting?

2002-11-06 Thread Kurtis
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

RE: Hash Sorting?

2002-11-06 Thread Timothy Johnson
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

RE: Hash Sorting?

2002-11-06 Thread Perry, Alan
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

RE: Hash Sorting?

2002-11-06 Thread Timothy Johnson
){ do something... } which I think is what you want. -Original Message- From: Kurtis [mailto:kurtis@;asdal.net] Sent: Wednesday, November 06, 2002 3:01 PM To: [EMAIL PROTECTED] Subject: Hash Sorting? Hello all.. Does anyone know how to sort a hash in ascending order on the value

Hash Sorting?

2002-11-06 Thread Kurtis
Hello all.. Does anyone know how to sort a hash in ascending order on the value? If possible, a little example! Thanks, Kurtis