Re: Sorting hash by element

2001-06-16 Thread Paul Johnson
On Sat, Jun 16, 2001 at 09:31:13AM -0700, Peter Scott wrote: > At 09:15 AM 6/16/2001 -0700, Ron Anderson wrote: > > > >And can I sort the hash by last name and then first name? > > Consider using instead a hash-of-hashes or hash-of-arrays(perldoc perllol). And when you need more efficiency type

Re: Sorting hash by element

2001-06-16 Thread Me
> But, if you did, I think this should work: But then it is saturday morning. Sigh. Ignore my attempt; use Peter's. > sub room { my $s = $shash{$_}; (split /\t/)[2] }; Wrong, twice. You wanted lastname, not room. And the split isn't working on the right thing. Peter's solution is clearer, n

Re: Sorting hash by element

2001-06-16 Thread Me
> $shash{"student1"} = join("\t", ("bob", "tyson", "room5")); > $shash{"student2"} = join("\t", ("ron", "anderson", "room4")); > $shash{"student3"} = join("\t", ("dave", "lee", "room2")); > $shash{"student4"} = join("\t", ("tim", "barker", "room3")); > $shash{"student5"} = join("\t", ("roger", "fa

Re: Sorting hash by element

2001-06-16 Thread Peter Scott
At 09:15 AM 6/16/2001 -0700, Ron Anderson wrote: >Hi! > >Using the following hash as an example: > >$shash{"student1"} = join("\t", ("bob", "tyson", "room5")); >$shash{"student2"} = join("\t", ("ron", "anderson", "room4")); >$shash{"student3"} = join("\t", ("dave", "lee", "room2")); >$shash{"stude

Sorting hash by element

2001-06-16 Thread Ron Anderson
Hi! Using the following hash as an example: $shash{"student1"} = join("\t", ("bob", "tyson", "room5")); $shash{"student2"} = join("\t", ("ron", "anderson", "room4")); $shash{"student3"} = join("\t", ("dave", "lee", "room2")); $shash{"student4"} = join("\t", ("tim", "barker", "room3")); $shash{"s