> $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", "farley", "room1"));
> 
> How can I sort the hash by, for example, last name?

If you want to do that, then I don't think you should store
the name/room info as a single tab delimited string.

But, if you did, I think this should work:

    sub room { my $s = $shash{$_}; (split /\t/)[2] };

    @keys = sort { room($a) cmp room($b) } (keys %shash);



Reply via email to